def test_spectrum_constructor_no_background(): ebounds = ChannelSet.from_list_of_edges(np.array([0,1,2,3,4,5])) obs_spectrum = BinnedSpectrum(counts=np.ones(len(ebounds)),exposure=1,ebounds=ebounds, is_poisson=True) assert np.all(obs_spectrum.counts == obs_spectrum.rates) specLike = SpectrumLike('fake', observation=obs_spectrum, background=None) specLike.__repr__()
def test_spectrum_constructor_no_background(): ebounds = ChannelSet.from_list_of_edges(np.array([0, 1, 2, 3, 4, 5])) obs_spectrum = BinnedSpectrum(counts=np.ones(len(ebounds)), exposure=1, ebounds=ebounds, is_poisson=True) assert np.all(obs_spectrum.counts == obs_spectrum.rates) specLike = SpectrumLike("fake", observation=obs_spectrum, background=None) specLike.__repr__()
def spectrum_addition(obs_spectrum_1,obs_spectrum_2,obs_spectrum_incompatible,addition,addition_proof): obs_spectrum = addition(obs_spectrum_1, obs_spectrum_2) addition_proof(obs_spectrum_1, obs_spectrum_2, obs_spectrum) assert obs_spectrum_1.exposure + obs_spectrum_2.exposure == obs_spectrum.exposure assert np.all(obs_spectrum.counts == obs_spectrum.rates * obs_spectrum.exposure) specLike = SpectrumLike('fake', observation=obs_spectrum, background=None) assert obs_spectrum.count_errors is None or obs_spectrum.count_errors.__class__ == np.ndarray specLike.__repr__()
def spectrum_addition(obs_spectrum_1, obs_spectrum_2, obs_spectrum_incompatible, addition, addition_proof): obs_spectrum = addition(obs_spectrum_1, obs_spectrum_2) addition_proof(obs_spectrum_1, obs_spectrum_2, obs_spectrum) assert obs_spectrum_1.exposure + obs_spectrum_2.exposure == obs_spectrum.exposure assert np.all(obs_spectrum.counts == obs_spectrum.rates * obs_spectrum.exposure) specLike = SpectrumLike('fake', observation=obs_spectrum, background=None) assert obs_spectrum.count_errors is None or obs_spectrum.count_errors.__class__ == np.ndarray specLike.__repr__()