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 __init__(self, name, units, points): super(JArrayGenerator, self).__init__() points = points.tolist() # Convert from array to list self.name = name self.generator = ArrayGenerator(name, units, points) logging.debug(self.generator.to_dict())
def test_array_positions(self): points = [0., 1., 2., 2.5, 3.0, 4.0, 4.5] bounds = [-0.5, 0.5, 1.5, 2.25, 2.75, 3.5, 4.25, 4.75] g = ArrayGenerator("x", "mm", points) g.prepare_positions() g.prepare_bounds() self.assertEqual(points, g.positions["x"].tolist()) self.assertEqual(bounds, g.bounds["x"].tolist())
def __init__(self, name, units, points): super(JArrayGenerator, self).__init__() points = points.tolist() # Convert from array to list self.name = name array_gen = ArrayGenerator(name, units, points) self.generator = CompoundGenerator([array_gen], [], []) self.generator.prepare() logging.debug(self.generator.to_dict())
def test_to_dict(self): points = [0., 0., 1., 2., 0.5, 2.7, 1.3, 4.0] expected = {} expected["typeid"] = "scanpointgenerator:generator/ArrayGenerator:1.0" expected["axis"] = "x" expected["units"] = "cm" expected["points"] = points expected["alternate"] = True g = ArrayGenerator("x", "cm", points, True) self.assertEqual(expected, g.to_dict())
def test_1d_init(self): g = ArrayGenerator("x", "mm", [0, 1, 2, 3]) self.assertEqual({"x": "mm"}, g.axis_units()) self.assertEqual(["x"], g.axes)