def test_bad_access_error(uncal_spec):
    """Test trying to access coeffs not yet supplied"""

    cal = bq.LinearEnergyCal()
    with pytest.raises(bq.EnergyCalError):
        cal.slope
    with pytest.raises(bq.EnergyCalError):
        cal.offset
def test_methods_rm_calpoint():
    """Test rm_calpoint"""

    cal = bq.LinearEnergyCal()
    cal.new_calpoint(32, 661.7)
    cal.rm_calpoint(661.7)
    cal.rm_calpoint(1460.83)
    assert len(cal.calpoints) == 0
    assert len(cal.channels) == 0
    assert len(cal.energies) == 0
def test_methods_add_calpoint():
    """Test add_calpoint"""

    cal = bq.LinearEnergyCal()
    cal.add_calpoint(32, 661.7)
    cal.add_calpoint(67, 1460.83)
    cal.add_calpoint(35, 661.7)
    assert len(cal.calpoints) == 2
    assert len(cal.channels) == 2
    assert len(cal.energies) == 2
def test_methods_new_calpoint():
    """Test new_calpoint"""

    cal = bq.LinearEnergyCal()
    cal.new_calpoint(32, 661.7)
    cal.new_calpoint(67, 1460.83)
    with pytest.raises(bq.EnergyCalError):
        cal.new_calpoint(35, 661.7)
    assert len(cal.calpoints) == 2
    assert len(cal.channels) == 2
    assert len(cal.energies) == 2
Exemple #5
0
def test_linear_bad_fitting():
    """Test fitting - too few calpoints (EnergyCalBase.update_fit())"""

    chlist = (67, 133)
    kevlist = (661.7, 1460.83)
    cal = bq.LinearEnergyCal.from_points(chlist=chlist, kevlist=kevlist)
    cal.update_fit()

    cal = bq.LinearEnergyCal()
    with pytest.raises(bq.EnergyCalError):
        cal.update_fit()

    chlist, kevlist = (67, ), (661.7, )
    cal = bq.LinearEnergyCal.from_points(chlist=chlist, kevlist=kevlist)
    with pytest.raises(bq.EnergyCalError):
        cal.update_fit()
def test_construction_empty():
    """Test empty construction"""

    bq.LinearEnergyCal()
def test_calibration_not_initialized_error(uncal_spec):
    """Test that calling apply_calibration on empty calibration causes an error"""

    cal = bq.LinearEnergyCal()
    with pytest.raises(bq.EnergyCalError):
        uncal_spec.apply_calibration(cal)
def test_linear_bad_fitting():
    """Test linear fitting - too few calpoints (EnergyCalBase.update_fit())"""

    cal = bq.LinearEnergyCal()
    with pytest.raises(bq.EnergyCalError):
        cal.update_fit()