def test_filter_directions(self): lp = tunnel.LatticePath(np.zeros(3), np.array((1, 0, 0))) expected_directions = np.array( ((1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1))) self.assertTrue( np.array_equal(expected_directions, lp.filter_directions()))
def test_next_along_110(self): lp = tunnel.LatticePath(np.zeros(3), np.array((3, 3, 0))) lattice_point_iter = iter(lp) self.assertTrue( np.array_equal(np.array((1, 1, 0)), next(lattice_point_iter))) self.assertTrue( np.array_equal(np.array((2, 2, 0)), next(lattice_point_iter))) self.assertTrue( np.array_equal(np.array((3, 3, 0)), next(lattice_point_iter))) with self.assertRaises(StopIteration): next(lattice_point_iter)
def test_next_along_210(self): lp = tunnel.LatticePath(np.zeros(3), np.array((2, 1, 0))) lattice_point_iter = iter(lp) # The point (1, 0, 0) happens to be first in the list of distances, # but the point (1, 1, 0) is equally close to the line. self.assertTrue( np.array_equal(np.array((1, 0, 0)), next(lattice_point_iter))) self.assertTrue( np.array_equal(np.array((2, 1, 0)), next(lattice_point_iter))) with self.assertRaises(StopIteration): next(lattice_point_iter)
def setUp(self) -> None: self.r0 = np.array((1, 1, -3)) self.r1 = np.array((1, 4, 1)) self.lp = tunnel.LatticePath(self.r0, self.r1)