def test_distance(): cell1 = Mock() cell2 = Mock() A = lambda *x: numpy.array(x) cell1.position = A(2.3, 4.5, 6.7) cell2.position = A(2.3, 4.5, 6.7) assert_equal(space.distance(cell1, cell2), 0.0) cell2.position = A(5.3, 4.5, 6.7) assert_equal(space.distance(cell1, cell2), 3.0) cell2.position = A(5.3, 8.5, 6.7) assert_equal(space.distance(cell1, cell2), 5.0) cell2.position = A(5.3, 8.5, -5.3) assert_equal(space.distance(cell1, cell2), 13.0) assert_equal(space.distance(cell1, cell2, mask=A(0,1)), 5.0) assert_equal(space.distance(cell1, cell2, mask=A(2)), 12.0) assert_equal(space.distance(cell1, cell2, offset=A(-3.0, -4.0, 12.0)), 0.0) cell2.position = A(10.6, 17.0, -10.6) assert_equal(space.distance(cell1, cell2, scale_factor=0.5), 13.0) cell2.position = A(-1.7, 8.5, -5.3) assert_equal(space.distance(cell1, cell2, periodic_boundaries=A(7.0, 1e12, 1e12)), 13.0)
def test_distance(): cell1 = Mock() cell2 = Mock() A = lambda *x: np.array(x) cell1.position = A(2.3, 4.5, 6.7) cell2.position = A(2.3, 4.5, 6.7) assert_equal(space.distance(cell1, cell2), 0.0) cell2.position = A(5.3, 4.5, 6.7) assert_equal(space.distance(cell1, cell2), 3.0) cell2.position = A(5.3, 8.5, 6.7) assert_equal(space.distance(cell1, cell2), 5.0) cell2.position = A(5.3, 8.5, -5.3) assert_equal(space.distance(cell1, cell2), 13.0) assert_equal(space.distance(cell1, cell2, mask=A(0, 1)), 5.0) assert_equal(space.distance(cell1, cell2, mask=A(2)), 12.0) assert_equal(space.distance(cell1, cell2, offset=A(-3.0, -4.0, 12.0)), 0.0) cell2.position = A(10.6, 17.0, -10.6) assert_equal(space.distance(cell1, cell2, scale_factor=0.5), 13.0) cell2.position = A(-1.7, 8.5, -5.3) assert_equal(space.distance(cell1, cell2, periodic_boundaries=A(7.0, 1e12, 1e12)), 13.0)