code: def rebin(self, *factors, **kwargs):
          
          if not HAVE_SCIPY:
              raise NotImplementedError("Rebinning requires scipy.ndimage")
          if any([x != 'order' for x in kwargs.keys()]):
              raise ValueError("Only 'order' keyword argument is accepted. Yeah, this is confusing.. blame python 2.")
          order = kwargs.get('order', 1)
  
          # Construct a new histogram
          mh = self.similar_blank_histogram()
  
          if not len(factors) == self.dimensions:
              raise ValueError("You must pass %d rebin factors to rebin a %d-dimensional histogram" % (
                  self.dimensions, self.dimensions
              ))
  
          # Zoom the bin edges.
          # It's a bit tricky for non-uniform bins:
          # we first construct a linear interpolator to take
          # fraction along axis -> axis coordinate according to current binning.
          # Then we feed it the new desired binning fractions.
          for i, f in enumerate(factors):
              x = self.bin_edges[i]
              mh.bin_edges[i] = np.interp(
                  x=np.linspace(0, 1, (len(x) - 1) * f + 1),
                  xp=np.linspace(0, 1, len(x)),
                  fp=x)
  
          # Rebin the histogram using ndimage.zoom, then renormalize
          mh.histogram = zoom(self.histogram, factors, order=order)
          mh.histogram *= self.histogram.sum() / mh.histogram.sum()
          # mh.histogram /= np.product(factors)
  
          return mh
docs: Return a new histogram that is 'rebinned' (zoomed) by factors (tuple of floats) along each dimensions
            factors: tuple with zoom factors along each axis. e.g. 2 = double number of bins, 0.5 = halve them.
            order: Order for spline interpolation in scipy.ndimage.zoom. Defaults to  linear interpolation (order=1).
  
          The only accepted keyword argument is 'order'!!! (python 2 is not nice)
  
          The normalization is set to the normalization of the current histogram
          The factors don't have to be integers or fractions: scipy.ndimage.zoom deals with the rebinning arcana.