Example #1
0
def time_spatial_hash_nnps(pa, nbrs, num_particles):
    start_time = time.time()
    nn = SpatialHashNNPS([pa])
    nn.set_context(0,0)
    for i in range(num_particles):
        nn.get_nearest_neighbours(0,0,i,nbrs)
    return time.time() - start_time
Example #2
0
 def test_spatial_hash_variable_radius(self):
     print ""
     for key in self.dataset_variable_radius:
         x, y, z, h = self.dataset_variable_radius[key]
         pa = get_particle_array(x=x, y=y, z=z, h=h)
         qid = randint(0,pa.get_number_of_particles()-1)
         nn_bf = brute_force_neighbours(pa, pa.x[qid], pa.y[qid],
                 pa.z[qid], pa.h[qid])
         sp = SpatialHashNNPS([pa])
         nn_sp = UIntArray()
         sp.set_context(0,0)
         sp.get_nearest_neighbours(0,0,qid,nn_sp)
         print " - " + key
         assert equal(nn_bf, nn_sp)
Example #3
0
 def test_spatial_hash_large_num_cells(self):
     '''
     Tests SpatialHashNNPS for large number of cells.
     Fails with a segmentation fault.
     '''
     print ""
     for key in self.dataset_large_domain:
         x, y, z, h = self.dataset_large_domain[key]
         pa = get_particle_array(x=x, y=y, z=z, h=h)
         qid = randint(0,pa.get_number_of_particles()-1)
         nn_bf = brute_force_neighbours(pa, pa.x[qid], pa.y[qid],
                 pa.z[qid], pa.h[qid])
         sp = SpatialHashNNPS([pa])
         nn_sp = UIntArray()
         sp.set_context(0,0)
         sp.get_nearest_neighbours(0,0,qid,nn_sp)
         print " - " + key
         assert equal(nn_bf, nn_sp)