Beispiel #1
0
 def test_histogram(self):
     # in this special case, cf.histogram and np.histogram must yield equal results
     # check hist and edges
     cfh, cfe = cf.histogram(self.data, bins=20, range=(0,1), shape=0)
     nph, npe = np.histogram(self.data, bins=20, range=(0,1))
     self.assertListEqual(list(nph), list(cfh))
     self.assertListEqual(list(npe), list(cfe))
Beispiel #2
0
 def test_histogramo2w(self):
     cfh, cfe = cf.histogram(self.data, bins=100, range=(0.0,1.0), shape=2, weights=self.weights)
     nph, npe = np.histogram(self.data, bins=100, range=(0.0,1.0), weights=self.weights)
     # just check that no mass is lost (cfh.base includes ghost cells)
     totalmass = np.sum(self.weights)
     self.assertAlmostEqual(np.sum(cfh.base) - totalmass, 0)
     self.assertAlmostEqual(np.sum(nph) - totalmass, 0)
     self.assertListEqual(list(npe), list(cfe))
Beispiel #3
0
 def test_histogramw(self):
     # in this special case, cf.histogram and np.histogram must yield equal results
     # check hist and edges
     cfh, cfe = cf.histogram(self.data, bins=100, range=(0,1), shape=0, weights=self.weights)
     nph, npe = np.histogram(self.data, bins=100, range=(0,1), weights=self.weights)
     diff = np.abs(cfh - nph)
     self.assertAlmostEqual(np.sum(diff), 0)
     self.assertListEqual(list(npe), list(cfe))
Beispiel #4
0
 def test_histogramo3(self):
     cfh, cfe = cf.histogram(self.data, bins=100, range=(0.0,1.0), shape=3)
     # just check that no mass is lost (cfh.base includes ghost cells)
     totalmass = len(self.data)
     self.assertAlmostEqual(np.sum(cfh.base) - totalmass, 0)