def test_count_symmetric(): pos1 = numpy.random.uniform(size=(1000000, 3)).astype('f4') pos2 = numpy.array([[0.3, 0.5, 0.1]], dtype='f4') tree1 = KDTree(pos1).root tree2 = KDTree(pos2).root assert_equal(tree2.count(tree1, (0, 0.1, 1.0)), tree1.count(tree2, (0, 0.1, 1.0)))
def test_enum_count_agree(): pos1 = numpy.random.uniform(size=(1000, 3)).astype('f4') pos2 = numpy.random.uniform(size=(1000, 3)).astype('f4') tree1 = KDTree(pos1).root tree2 = KDTree(pos2).root N = [0] def process1(r, i, j): N[0] += len(r) tree1.enum(tree2, rmax=1.0, process=process1) c = tree1.count(tree2, r=1.0) assert_equal(N[0], c)
def test_count(): numpy.random.seed(1234) pos1 = numpy.random.uniform(size=(1000, 3)).astype('f8') pos2 = numpy.random.uniform(size=(1000, 3)).astype('f8') dist = ((pos1[:, None, :] - pos2[None, :, :])**2).sum(axis=-1) truth = (dist < 1).sum() tree1 = KDTree(pos1).root tree2 = KDTree(pos2).root c = tree1.count(tree2, r=1.0) assert_equal(c, truth)
def test_count(): numpy.random.seed(1234) pos1 = numpy.random.uniform(size=(1000, 3)).astype('f8') pos2 = numpy.random.uniform(size=(1000, 3)).astype('f8') dist = ((pos1[:, None, :] - pos2[None, :, :]) ** 2).sum(axis=-1) truth = (dist < 1).sum() tree1 = KDTree(pos1).root tree2 = KDTree(pos2).root c = tree1.count(tree2, r=1.0) assert_equal(c, truth)