Example #1
0
def test_compressed_octree_has_lesser_depth_than_octree():
    N = 50
    x, y, z = np.mgrid[0:1:N * 1j, 0:1:N * 1j, 0:1:N * 1j]
    x = x.ravel()
    y = y.ravel()
    z = z.ravel()
    h = np.ones_like(x)

    pa = get_particle_array(x=x, y=y, z=z, h=h)

    x1 = np.array([20])
    y1 = np.array([20])
    z1 = np.array([20])

    # For a dataset where one particle is far away from a
    # cluster of particles
    pa.add_particles(x=x1, y=y1, z=z1)
    tree = Octree(10)
    comp_tree = CompressedOctree(10)

    depth_tree = tree.build_tree(pa)
    depth_comp_tree = comp_tree.build_tree(pa)

    # Test that the depth of compressed octree for the same
    # leaf_max_particles is lesser than that of octree
    assert depth_comp_tree < depth_tree
Example #2
0
def test_single_level_compressed_octree():
    N = 50
    x, y, z = np.mgrid[0:1:N * 1j, 0:1:N * 1j, 0:1:N * 1j]
    x = x.ravel()
    y = y.ravel()
    z = z.ravel()
    h = np.ones_like(x)

    pa = get_particle_array(x=x, y=y, z=z, h=h)

    # For maximum leaf particles greater that total number
    # of particles
    tree = CompressedOctree(pa.get_number_of_particles() + 1)
    tree.build_tree(pa)
    # Test that depth of the tree is 1
    assert tree.depth == 1
Example #3
0
    def setUp(self):
        N = int(1e5)
        self.x = np.linspace(0, 1, num=N)
        self.y = np.zeros_like(self.x)
        self.z = np.zeros_like(self.x)
        self.h = np.ones_like(self.x)

        self.tree = CompressedOctree(100)
Example #4
0
    def setUp(self):
        N = 500
        x, y = np.mgrid[0:1:N * 1j, 0:1:N * 1j]
        self.x = x.ravel()
        self.y = y.ravel()
        self.z = np.zeros_like(self.x)
        self.h = np.ones_like(self.x)

        self.tree = CompressedOctree(10)
Example #5
0
    def setUp(self):
        N = 50
        x, y, z = np.mgrid[-1:1:N * 1j, -1:1:N * 1j, -1:1:N * 1j]
        self.x = x.ravel()
        self.y = y.ravel()
        self.z = z.ravel()

        x1 = np.array([-1e-20])
        y1 = np.array([1e-20])
        z1 = np.array([1e-20])

        self.x = np.concatenate([self.x, x1])
        self.y = np.concatenate([self.y, y1])
        self.z = np.concatenate([self.z, z1])

        self.h = np.ones_like(self.x)

        self.tree = CompressedOctree(10)