def test_squashed_multiplied_snake_scan() -> None: inst = Line(z, 1, 2, 2) * Squash( Line(y, 1, 2, 2) * ~Line.bounded(x, 3, 7, 2) * Static.duration(9, 2)) assert inst.axes() == [z, y, x, DURATION] dimz, dimxyt = inst.create_dimensions() for d in dimxyt.midpoints, dimxyt.lower, dimxyt.upper: assert d == { x: pytest.approx([4, 4, 6, 6, 6, 6, 4, 4]), y: pytest.approx([1, 1, 1, 1, 2, 2, 2, 2]), DURATION: pytest.approx([9, 9, 9, 9, 9, 9, 9, 9]), } assert dimz.midpoints == dimz.lower == dimz.upper == { z: pytest.approx([1, 2]) }
def test_blended_repeat() -> None: # Check that if we blend the REPEATS don't change bs = str() spec = repeat(~Line.bounded(bs, 11, 19, 1), 10, blend=True) dim = spec.path().consume() assert len(dim) == 10 assert dim.lower == { bs: pytest.approx([11, 19, 11, 19, 11, 19, 11, 19, 11, 19]), "REPEAT": pytest.approx([10, 10, 10, 10, 10, 10, 10, 10, 10, 10]), } assert dim.upper == { bs: pytest.approx([19, 11, 19, 11, 19, 11, 19, 11, 19, 11]), "REPEAT": pytest.approx([10, 10, 10, 10, 10, 10, 10, 10, 10, 10]), } assert dim.midpoints == { bs: pytest.approx([15, 15, 15, 15, 15, 15, 15, 15, 15, 15]), "REPEAT": pytest.approx([10, 10, 10, 10, 10, 10, 10, 10, 10, 10]), }
def test_beam_selector() -> None: # Beam selector scan moves bounded between midpoints and lower and upper bounds at # maximum speed. Turnaround sections are where it sends the triggers bs = str() spec = repeat(~Line.bounded(bs, 11, 19, 1), 10) dim = spec.path().consume() assert len(dim) == 10 assert dim.lower == { bs: pytest.approx([11, 19, 11, 19, 11, 19, 11, 19, 11, 19]), "REPEAT": pytest.approx([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), } assert dim.upper == { bs: pytest.approx([19, 11, 19, 11, 19, 11, 19, 11, 19, 11]), "REPEAT": pytest.approx([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), } assert dim.midpoints == { bs: pytest.approx([15, 15, 15, 15, 15, 15, 15, 15, 15, 15]), "REPEAT": pytest.approx([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), }
def test_many_point_bounded_line() -> None: inst = Line.bounded(x, 0, 1, 4) assert inst == Line(x, 0.125, 0.875, 4)
def test_one_point_bounded_line() -> None: inst = Line.bounded(x, 0, 1, 1) assert inst == Line(x, 0.5, 1.5, 1)