def test_array_positions_from_line_non_matching_bounds(self): genone = LineGenerator("x", "mm", 1.0, 9.0, 5) gentwo = LineGenerator("x", "mm", 20, 24, 5) g = ConcatGenerator([genone, gentwo]) g.prepare_positions() with self.assertRaises(AssertionError): g.prepare_bounds()
def test_array_positions_from_array(self): genone = ArrayGenerator("x", "mm", [1.0, 2.0, 3.0, 4.0, 5.0]) gentwo = ArrayGenerator("x", "mm", [6.0, 7.0, 8.0, 9.0, 0.0]) g = ConcatGenerator([genone, gentwo]) positions = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0] bounds = [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 4.5, -4.5] g.prepare_positions() g.prepare_bounds() self.assertEqual(positions, g.positions['x'].tolist()) self.assertEqual(bounds, g.bounds['x'].tolist())
def test_array_positions_from_line(self): genone = LineGenerator("x", "mm", 1.0, 9.0, 5) gentwo = LineGenerator("x", "mm", 11, 19, 5) g = ConcatGenerator([genone, gentwo]) positions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19] bounds = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20] g.prepare_positions() g.prepare_bounds() self.assertEqual(positions, g.positions['x'].tolist()) self.assertEqual(bounds, g.bounds['x'].tolist())
def test_array_positions_from_three_(self): genone = LineGenerator("x", "mm", 1.0, 9.0, 5) gentwo = LineGenerator("x", "mm", 11, 19, 5) genthree = LineGenerator("x", "mm", 21, 29, 5) g = ConcatGenerator([genone, gentwo, genthree]) positions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29] bounds = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30] g.prepare_positions() g.prepare_bounds() self.assertEqual(positions, g.positions['x'].tolist()) self.assertEqual(bounds, g.bounds['x'].tolist())
def test_array_positions_from_2D_line(self): genone = LineGenerator(["x", "y"], ["mm", "mm"], [2., -2.], [4., -4.], 3) gentwo = LineGenerator(["x", "y"], ["mm", "mm"], [5., -4.], [7., -2.], 3) g = ConcatGenerator([genone, gentwo]) x_positions = [2.0, 3.0, 4.0, 5.0, 6.0, 7.0] y_positions = [-2.0, -3.0, -4.0, -4.0, -3.0, -2.0] x_bounds = [1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5] y_bounds = [-1.5, -2.5, -3.5, -4.5, -3.5, -2.5, -1.5] g.prepare_positions() g.prepare_bounds() self.assertEqual(x_positions, g.positions['x'].tolist()) self.assertEqual(y_positions, g.positions['y'].tolist()) self.assertEqual(x_bounds, g.bounds['x'].tolist()) self.assertEqual(y_bounds, g.bounds['y'].tolist())