unbin_array

Contents

unbin_array#

unbin_array(arr, binfactor)[source]#

Unbin (by repetition) an N-D array by a given factor.

Let arr.shape = (s1, s2, ...) and binfactor = (b1, b2, ...) (same length), the new shape will be (s1*b1, s2*b2, ...).

Parameters:
  • arr (numpy.ndarray) – Input array.

  • binfactor (int or tuple of int) – Unbin factor. If an integer, it is used for all axes. If its length is lower than arr.ndim, it is prepended with 1’s.

Returns:

numpy.ndarray – Array of shape (s1*b1, s2*b2, ...), each input element being repeated b1 x b2 x ... times.

See also

bin_array

The opposite operation.

Examples

>>> unbin_array(np.arange(2*3).reshape(2, 3), 2).shape
(4, 6)
>>> unbin_array(np.arange(2*3).reshape(2, 3), (2,)).shape
(2, 6)
>>> unbin_array(np.arange(2*3).reshape(2, 3), (2, 1)).shape
(4, 3)