docs: def array2qimage(array, normalize = False):
      """Convert a 2D or 3D numpy array into a 32-bit QImage_.  The
      first dimension represents the vertical image axis; the optional
      third dimension is supposed to contain 1-4 channels:
  
      ========= ===================
      #channels interpretation
      ========= ===================
              1 scalar/gray
              2 scalar/gray + alpha
              3 RGB
              4 RGB + alpha
      ========= ===================
  
      Scalar data will be converted into corresponding gray RGB triples;
      if you want to convert to an (indexed) 8-bit image instead, use
      `gray2qimage` (which cannot support an alpha channel though).
  
      The parameter `normalize` can be used to normalize an image's
      value range to 0..255:
  
      `normalize` = (nmin, nmax):
        scale & clip image values from nmin..nmax to 0..255
  
      `normalize` = nmax:
        lets nmin default to zero, i.e. scale & clip the range 0..nmax
        to 0..255
  
      `normalize` = True:
        scale image values to 0..255 (same as passing (array.min(),
        array.max()))
  
      If `array` contains masked values, the corresponding pixels will
      be transparent in the result.  Thus, the result will be of
      QImage.Format_ARGB32 if the input already contains an alpha
      channel (i.e. has shape (H,W,4)) or if there are masked pixels,
      and QImage.Format_RGB32 otherwise.
  
      :param array: image data which should be converted (copied) into a QImage_
      :type array: 2D or 3D numpy.ndarray_ or `numpy.ma.array <masked arrays>`_
      :param normalize: normalization parameter (see above, default: no value changing)
      :type normalize: bool, scalar, or pair
      :rtype: QImage_ with RGB32 or ARGB32 format"""
      if _np.ndim(array) == 2:
          array = array[...,None]
      elif _np.ndim(array) != 3:
          raise ValueError("array2qimage can only convert 2D or 3D arrays (got %d dimensions)" % _np.ndim(array))
      if array.shape[2] not in (1, 2, 3, 4):
          raise ValueError("array2qimage expects the last dimension to contain exactly one (scalar/gray), two (gray+alpha), three (R,G,B), or four (R,G,B,A) channels")
  
      h, w, channels = array.shape
  
      hasAlpha = _np.ma.is_masked(array) or channels in (2, 4)
      fmt = _qt.QImage.Format_ARGB32 if hasAlpha else _qt.QImage.Format_RGB32
  
      result = _qt.QImage(w, h, fmt)
  
      array = _normalize255(array, normalize)
  
      if channels >= 3:
          rgb_view(result)[:] = array[...,:3]
      else:
          rgb_view(result)[:] = array[...,:1] # scalar data
  
      alpha = alpha_view(result)
  
      if channels in (2, 4):
          alpha[:] = array[...,-1]
      else:
          alpha[:] = 255
  
      if _np.ma.is_masked(array):
          alpha[:]  *= _np.logical_not(_np.any(array.mask, axis = -1))
  
      return result