Exemple #1
0
 def rebin(self,
           new_shape=None,
           scale=None,
           crop=False,
           out=None,
           rechunk=True):
     factors = self._validate_rebin_args_and_get_factors(
         new_shape=new_shape, scale=scale)
     if _requires_linear_rebin(arr=self.data, scale=factors):
         if new_shape:
             raise NotImplementedError(
                 "Lazy rebin requires that the new shape is a divisor "
                 "of the original signal shape e.g. if original shape "
                 "(10| 6), new_shape=(5| 3) is valid, (3 | 4) is not.")
         else:
             raise NotImplementedError(
                 "Lazy rebin requires scale to be integer and divisor of the "
                 "original signal shape")
     axis = {ax.index_in_array: ax
             for ax in self.axes_manager._axes}[factors.argmax()]
     self._make_lazy(axis=axis, rechunk=rechunk)
     return super().rebin(new_shape=new_shape,
                          scale=scale,
                          crop=crop,
                          out=out)
Exemple #2
0
 def rebin(self, new_shape=None, scale=None,
           crop=False, out=None, rechunk=True):
     factors = self._validate_rebin_args_and_get_factors(
         new_shape=new_shape,
         scale=scale)
     if _requires_linear_rebin(arr=self.data, scale=factors):
         if new_shape:
             raise NotImplementedError(
                 "Lazy rebin requires that the new shape is a divisor "
                 "of the original signal shape e.g. if original shape "
                 "(10| 6), new_shape=(5| 3) is valid, (3 | 4) is not.")
         else:
             raise NotImplementedError(
                 "Lazy rebin requires scale to be integer and divisor of the "
                 "original signal shape")
     axis = {ax.index_in_array: ax
             for ax in self.axes_manager._axes}[factors.argmax()]
     self._make_lazy(axis=axis, rechunk=rechunk)
     return super().rebin(new_shape=new_shape,
                          scale=scale, crop=crop, out=out)