def test_compile_energy_grid(): '''This test just executes the doc string. Once we activate doctests, this test can be removed.''' elo, ehi, htable = compile_energy_grid([([1, 3, 5], [3, 5, 7]), ([0, 1, 2], [1, 2, 3])]) assert np.all(elo == [0, 1, 2, 3, 5]) assert np.all(ehi == [1, 2, 3, 5, 7]) assert np.all(htable[0][0] == [1, 3, 4])
def test_compile_energy_grid_3inputs(): '''Test more than two input grids''' elo, ehi, htable = compile_energy_grid([([1, 3, 5], [3, 5, 7]), ([0, 1, 2], [1, 2, 3]), ([0.5, 5.5, 7.5], [5.5, 7.5, 9])]) assert np.allclose(elo, [0., 0.5, 1., 2., 3., 5., 5.5, 7., 7.5]) assert np.allclose(ehi, [0.5, 1., 2., 3., 5., 5.5, 7., 7.5, 9.]) assert np.all(htable[0][0] == [2, 4, 5]) assert np.all(htable[2][1] == [5, 7, 8])
def _get_noticed_energy_list(self): grid = [] for id in self.pha.response_ids: arf, rmf = self.pha.get_response(id) indep = None if arf is not None: indep = arf.get_indep() elif rmf is not None: indep = rmf.get_indep() grid.append(indep) self.elo, self.ehi, self.table = compile_energy_grid(grid) self.lo, self.hi = DataPHA._hc / self.ehi, DataPHA._hc / self.elo