def test_histogram2do2w(self): # in this special case, cf.histogram2d and np.histogram2d must yield equal results # check hist and edges cfh, cfex, cfey = cf.histogram2d(self.datax, self.datay, weights=self.weights, bins=(20, 30), range=((0,1), (0,2)), shape=2) nph, npex, npey = np.histogram2d(self.datax, self.datay, weights=self.weights, bins=(20, 30), range=((0,1), (0,2))) totalmass = np.sum(self.weights) self.assertAlmostEqual(np.sum(cfh.base) - totalmass, 0) self.assertAlmostEqual(np.sum(nph) - totalmass, 0) self.assertListEqual(list(npex), list(cfex)) self.assertListEqual(list(npey), list(cfey))
def test_histogram2do3w(self): cfh, cfex, cfey = cf.histogram2d(self.datax, self.datay, weights=self.weights, bins=(20, 30), range=((0,1), (0,2)), shape=3) totalmass = np.sum(self.weights) self.assertAlmostEqual(np.sum(cfh.base) - totalmass, 0)