示例#1
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
示例#2
0
def test_calibration_interpolation():
    """Test Calibration.from_interpolation."""
    Calibration.from_interpolation(points_x[:2], points_y[:2])
    with pytest.raises(CalibrationError):
        Calibration.from_interpolation(points_x[:1], points_y[:1])