Пример #1
0
def test_calibration_misc():
    """Miscellaneous tests to increase test coverage."""
    cal1 = Calibration.from_linear([2.0, 3.0])
    cal2 = Calibration.from_polynomial([2.0, 3.0, 7.0])
    with pytest.raises(CalibrationError):
        cal1 != 0
    assert cal1 != cal2

    # bad number of arguments
    with pytest.raises(CalibrationError):
        Calibration.from_linear([2.0])
    Calibration.from_linear([2.0, 3.0])
    with pytest.raises(CalibrationError):
        Calibration.from_linear([2.0, 3.0, 4.0])

    # bad number of arguments
    with pytest.raises(CalibrationError):
        Calibration.from_polynomial([2.0])
    Calibration.from_polynomial([2.0, 3.0])
    Calibration.from_polynomial([2.0, 3.0, 4.0])

    # bad number of arguments
    with pytest.raises(CalibrationError):
        Calibration.from_sqrt_polynomial([2.0])
    Calibration.from_sqrt_polynomial([2.0, 3.0])
    Calibration.from_sqrt_polynomial([2.0, 3.0, 4.0])
Пример #2
0
def make_calibration(name, args):
    """Make an instance of the desired Calibration type."""
    attrs = {"comment": "Test of Calibration class", "name": name}
    if name.startswith("lin"):
        cal = Calibration.from_linear(*args, **attrs, domain=domain)
    elif name.startswith("poly"):
        cal = Calibration.from_polynomial(*args, **attrs, domain=domain)
    elif name.startswith("sqrt"):
        cal = Calibration.from_sqrt_polynomial(*args, **attrs, domain=domain)
    elif name.startswith("interp"):
        cal = Calibration.from_interpolation(points_x, points_y, **attrs, domain=domain)
    else:
        cal = Calibration(*args, **attrs, domain=domain)
    return cal