Ejemplo n.º 1
0
def test_check_limits(hw):
    det = hw.det
    motor = hw.motor
    # The motor object does not currently implement limits.
    # Use an assert to help us out if this changes in the future.
    assert not hasattr(motor, 'limits')

    # # check_limits should warn if it can't find check_value
    # TODO: Is there _any_ object to test?
    # with pytest.warns(UserWarning):
    #     check_limits(scan([det], motor, -1, 1, 3))

    # monkey-patch some limits
    motor.limits = (-2, 2)
    # check_limits should do nothing here
    check_limits(scan([det], motor, -1, 1, 3))

    # check_limits should error if limits are exceeded only if object raises
    # this object does not raise
    check_limits(scan([det], motor, -3, 3, 3))

    # check_limits should raise if limits are equal only if object raises
    # this object does not raise
    motor.limits = (2, 2)
    check_limits(scan([det], motor, -1, 1, 3))
Ejemplo n.º 2
0
def test_hkl_scan(fourc):
    fourc.move(1, 1, 1)
    assert (check_limits(
        # fmt: off
        bp.scan(
            [fourc],
            fourc.h,
            0.9,
            1.1,
            fourc.k,
            0.9,
            1.1,
            fourc.l,
            0.9,
            1.1,
            33,
        )
        # fmt: on
    ) is None)
Ejemplo n.º 3
0
def test_hkl_range_error(fourc):
    with pytest.raises(ValueError) as exinfo:
        assert (check_limits(
            # fmt: off
            bp.scan(
                [fourc],
                fourc.h,
                0.9,
                1.1,
                fourc.k,
                0.9,
                1.1,
                fourc.l,
                0.09,
                123.1,
                33,
            )
            # fmt: on
        ) is None)
    assert "Unable to solve." in str(exinfo.value)
Ejemplo n.º 4
0
def test_check_limits(hw):
    det = hw.det
    motor = hw.motor
    # The motor object does not currently implement limits.
    # Use an assert to help us out if this changes in the future.
    assert not hasattr(motor, 'limits')

    # check_limits should warn if it can't find limits
    with pytest.warns(UserWarning):
        check_limits(scan([det], motor, -1, 1, 3))

    # monkey-patch some limits
    motor.limits = (-2, 2)
    # check_limits should do nothing here
    check_limits(scan([det], motor, -1, 1, 3))

    # check_limits should error if limits are exceeded
    with pytest.raises(LimitsExceeded):
        check_limits(scan([det], motor, -3, 3, 3))

    # check_limits should warn if limits are equal
    motor.limits = (2, 2)
    with pytest.warns(UserWarning):
        check_limits(scan([det], motor, -1, 1, 3))
Ejemplo n.º 5
0
def test_h00_scan(fourc):
    fourc.move(1, 0, 0)
    assert check_limits(bp.scan([fourc], fourc.h, 0.9, 1.1, fourc.l, 0, 0,
                                11)) is None
Ejemplo n.º 6
0
def test_hl_scan(fourc):
    fourc.move((1.2, 1.2, 0.001))
    assert check_limits(bp.scan([fourc], fourc.h, 0.9, 1.1, fourc.l, 0, 0,
                                11)) is None
Ejemplo n.º 7
0
def test_real_axis_range_error(fourc):
    with pytest.raises(LimitError) as exinfo:
        check_limits(bp.scan([fourc], fourc.tth, 10, 20000, 3))
    assert "not within limits" in str(exinfo.value)
Ejemplo n.º 8
0
def test_real_axis_range_multi(fourc):
    assert check_limits(bp.scan([fourc], fourc.tth, 10, 20, fourc.chi, 5, 7,
                                3)) is None
Ejemplo n.º 9
0
def test_axis_contention(fourc):
    # contention if move pseudo and real positioners together
    with pytest.raises(ValueError) as exinfo:
        check_limits(bp.scan([fourc], fourc.tth, 10, 20, fourc.k, 0, 0, 3))
    assert "mix of real and pseudo" in str(exinfo.value)
Ejemplo n.º 10
0
def test_real_axis(fourc):
    assert check_limits(bp.scan([fourc], fourc.tth, 10, 20, 3)) is None