Add test from SpectrumDatasetOnOff.create()
@@ -179,6 +179,20 @@ class TestSpectrumOnOff:
assert empty_dataset.background.energy.nbin == 2
assert empty_dataset.aeff.data.axis("energy").nbin == 3
assert empty_dataset.edisp.data.axis("e_reco").nbin == 2
+
+ def test_spectrumdatasetonoff_create(self):
+ e_reco = u.Quantity([0.1,1,10.], 'TeV')
+ e_true = u.Quantity([0.05, 0.5, 5, 20.], 'TeV')
+ empty_dataset = SpectrumDatasetOnOff.create(e_reco, e_true)
+
+ assert empty_dataset.counts.total_counts == 0
+ assert empty_dataset.data_shape[0] == 2
+ assert empty_dataset.counts_off.total_counts == 0
+ assert empty_dataset.counts_off.energy.nbin == 2
+ assert_allclose(empty_dataset.acceptance_off,1)
+ assert_allclose(empty_dataset.acceptance,1)
+ assert empty_dataset.acceptance.shape[0] == 2
+ assert empty_dataset.acceptance_off.shape[0] == 2
assert empty_dataset.livetime.value == 0
assert len(empty_dataset.gti.table) == 0
