def test_quadtree_similar_point(): # Introduce a point into a quad tree where a similar point already exists. # Test will hang if it doesn't complete. Xs = [] # check the case where points are actually different Xs.append(np.array([[1, 2], [3, 4]], dtype=np.float32)) # check the case where points are the same on X axis Xs.append(np.array([[1.0, 2.0], [1.0, 3.0]], dtype=np.float32)) # check the case where points are arbitrarily close on X axis Xs.append(np.array([[1.00001, 2.0], [1.00002, 3.0]], dtype=np.float32)) # check the case where points are the same on Y axis Xs.append(np.array([[1.0, 2.0], [3.0, 2.0]], dtype=np.float32)) # check the case where points are arbitrarily close on Y axis Xs.append(np.array([[1.0, 2.00001], [3.0, 2.00002]], dtype=np.float32)) # check the case where points are arbitrarily close on both axes Xs.append(np.array([[1.00001, 2.00001], [1.00002, 2.00002]], dtype=np.float32)) # check the case where points are arbitrarily close on both axes # close to machine epsilon - x axis Xs.append(np.array([[1, 0.0003817754041], [2, 0.0003817753750]], dtype=np.float32)) # check the case where points are arbitrarily close on both axes # close to machine epsilon - y axis Xs.append(np.array([[0.0003817754041, 1.0], [0.0003817753750, 2.0]], dtype=np.float32)) for X in Xs: counts = np.zeros(3, dtype="int64") _barnes_hut_tsne.check_quadtree(X, counts) m = "Tree consistency failed: unexpected number of points at root node" assert_equal(counts[0], counts[1], m) m = "Tree consistency failed: unexpected number of points on the tree" assert_equal(counts[0], counts[2], m)
def test_quadtree_similar_point(): # Introduce a point into a quad tree where a similar point already exists. # Test will hang if it doesn't complete. Xs = [] # check the case where points are actually different Xs.append(np.array([[1, 2], [3, 4]], dtype=np.float32)) # check the case where points are the same on X axis Xs.append(np.array([[1.0, 2.0], [1.0, 3.0]], dtype=np.float32)) # check the case where points are arbitrarily close on X axis Xs.append(np.array([[1.00001, 2.0], [1.00002, 3.0]], dtype=np.float32)) # check the case where points are the same on Y axis Xs.append(np.array([[1.0, 2.0], [3.0, 2.0]], dtype=np.float32)) # check the case where points are arbitrarily close on Y axis Xs.append(np.array([[1.0, 2.00001], [3.0, 2.00002]], dtype=np.float32)) # check the case where points are arbitraryily close on both axes Xs.append( np.array([[1.00001, 2.00001], [1.00002, 2.00002]], dtype=np.float32)) # check the case where points are arbitraryily close on both axes # close to machine epsilon - x axis Xs.append( np.array([[1, 0.0003817754041], [2, 0.0003817753750]], dtype=np.float32)) # check the case where points are arbitraryily close on both axes # close to machine epsilon - y axis Xs.append( np.array([[0.0003817754041, 1.0], [0.0003817753750, 2.0]], dtype=np.float32)) for X in Xs: counts = np.zeros(3, dtype='int64') _barnes_hut_tsne.check_quadtree(X, counts) m = "Tree consistency failed: unexpected number of points at root node" assert_equal(counts[0], counts[1], m) m = "Tree consistency failed: unexpected number of points on the tree" assert_equal(counts[0], counts[2], m)