def test_histogram3do2w(self):
     # in this special case, cf.histogram2d and np.histogram2d must yield equal results
     # check hist and edges
     cfh, cfex, cfey, cfez = cf.histogram3d(self.datax, self.datay, self.dataz, weights=self.weights,
                                      bins=(20,30,40), range=((0,1), (0,2), (0,3)), shape=2)
     totalmass = np.sum(self.weights)
     self.assertAlmostEqual(np.sum(cfh.base) - totalmass, 0)
示例#2
0
 def test_histogram3do2(self):
     # in this special case, cf.histogram2d and np.histogram2d must yield equal results
     # check hist and edges
     cfh, cfex, cfey, cfez = cf.histogram3d(self.datax,
                                            self.datay,
                                            self.dataz,
                                            bins=(20, 30, 40),
                                            range=((0, 1), (0, 2), (0, 3)),
                                            shape=2)
     totalmass = len(self.datax)
     self.assertAlmostEqual(np.sum(cfh.base) - totalmass, 0)
示例#3
0
 def time3D(datax, datay, dataz, bins, weights, shape, tn):
     t = timeit.Timer(lambda: cf.histogram3d(datax,
                                             datay,
                                             dataz,
                                             range=((0.01, 0.99), (
                                                 0.01, 0.99), (0.01, 0.99)),
                                             bins=bins,
                                             weights=weights,
                                             shape=shape))
     tc = t.timeit(number=1) / 1.0
     ws = '       ' if weights is None else 'weights'
     print('3D, {:d} shape, {:s}: {:0.2e} sec -> factor {:5.2f} faster'.
           format(shape, ws, tc, tn / tc))
 def time3D(datax, datay, dataz, bins, weights, shape, tn):
     t = timeit.Timer(lambda: cf.histogram3d(datax, datay, dataz, range=((0.01,0.99),(0.01,0.99),(0.01,0.99)), bins=bins, weights=weights, shape=shape))
     tc = t.timeit(number=1)/1.0
     ws = '       ' if weights is None else 'weights'
     print('3D, {:d} shape, {:s}: {:0.2e} sec -> factor {:5.2f} faster'.format(shape, ws, tc, tn/tc))