def test_neighbors(): close = [[0.0, 0.0, 0.0], [0.1, 0.0, 0.0], [0.0, 0.1, 0.0], [0.0, 0.0, 0.1]] periodic = [1, 1, 1] # Testing single array assert neighbors.count_neighbors([0, 0, 0], close, periodic, 0.11) == 4 ix, c = neighbors.nearest_neighbors([0, 0, 0], close, periodic, 0.11) assert np.allclose(ix, [0, 1, 2, 3]) # Testing multiple arrays assert neighbors.count_neighbors([[0, 0, 0], [0.2, 0, 0]], close, periodic, 0.11) == [4, 1] ix, c = neighbors.nearest_neighbors([[0, 0, 0], [0.2, 0, 0]], close, periodic, 0.11) assert np.allclose(ix[0], [0, 1, 2, 3]) assert np.allclose(ix[1], [1]) assert np.allclose(c[0], close) assert np.allclose(c[1], [close[1]])
def test_neighbors(): close = [[0.0, 0.0, 0.0], [0.1, 0.0, 0.0], [0.0, 0.1, 0.0], [0.0, 0.0, 0.1]] periodic = [1, 1, 1] # Testing single array npeq_(count_neighbors([0, 0, 0], close, periodic, 0.11), 4) ix, c = nearest_neighbors([0, 0, 0], close, periodic, 0.11) npeq_(ix, [0, 1, 2, 3]) # Testing multiple arrays npeq_(count_neighbors([[0, 0, 0], [0.2, 0, 0]], close, periodic, 0.11), [4, 1]) ix, c = nearest_neighbors([[0, 0, 0], [0.2, 0, 0]], close, periodic, 0.11) npeq_(ix[0], [0, 1, 2, 3]) npeq_(ix[1], [1]) npeq_(c[0], close) npeq_(c[1], [close[1]])