def _add_random_energies(self, data, n_events): """Draw n_events random energies from the energy spectrum and add them to the data dict. """ es, rs = self._single_spectrum() energies = Hist1d.from_histogram(rs[:-1], es).get_random(n_events) data['energy'] = energies return data
def test_init_from_histogram(self): m = Hist1d.from_histogram([0, 1, 0], [0, 1, 2, 3]) self.assertEqual(m.histogram.tolist(), [0, 1, 0]) self.assertEqual(m.bin_centers.tolist(), [0.5, 1.5, 2.5])