def test_error_positional_parameters(cal_spec): """Test errors when to many positional parameters are provided""" with pytest.raises(bq.PlottingError): cal_spec.plot('x', 'x') with pytest.raises(bq.PlottingError): sp(cal_spec).plot('x', 'x')
def test_kwargs_SpectrumPlotter(uncal_spec): """Test kwargs, color and fmt in this case""" sp(uncal_spec).plot('--', color='#ffffff') assert plt.gca().get_lines()[0].get_linestyle() == '--' assert plt.gca().get_lines()[0].get_color() == '#ffffff' plt.close("all")
def test_kwargs_SpectrumPlotter(uncal_spec): """Test kwargs, color and fmt in this case""" sp(uncal_spec).plot("--", color="#ffffff") assert plt.gca().get_lines()[0].get_linestyle() == "--" assert plt.gca().get_lines()[0].get_color() == "#ffffff" plt.close("all")
def test_error_modes_cpskev(cal_spec): """Test error mode for cps mode""" cal_spec.livetime = 200 tsp = sp(cal_spec, ymode='cpskev') assert np.allclose(tsp.yerror, cal_spec.cpskev_uncs)
def test_error_modes_counts(uncal_spec): """Test error mode for counts mode""" tsp = sp(uncal_spec, ymode='counts') assert np.allclose(tsp.yerror, uncal_spec.counts_uncs)
def test_get_linthreshy(cal_spec_cps): """Test get linthreshy function""" tsp = sp(cal_spec_cps, linthreshy=1) assert tsp.linthreshy == 1
def test_get_xlim(cal_spec_cps): """Test get xlim function""" tsp = sp(cal_spec_cps, xlim='default') assert tsp.xlim == (cal_spec_cps.bin_edges_kev[0], cal_spec_cps.bin_edges_kev[-1])
def test_get_ylabel(cal_spec_cps): """Test get ylabel function""" tsp = sp(cal_spec_cps) assert tsp.ylabel == 'Countrate [1/s]'
def test_get_xlabel(cal_spec_cps): """Test get xlabel function""" tsp = sp(cal_spec_cps) assert tsp.xlabel == 'Energy [keV]'
def test_get_ymode(cal_spec_cps): """Test get ymode function""" tsp = sp(cal_spec_cps) assert tsp.ymode == 'cps'
def test_get_xmode(cal_spec_cps): """Test get xmode function""" tsp = sp(cal_spec_cps) assert tsp.xmode == 'energy'