docs: def image(img, cmap='gray', bar=False, nans=True, clim=None, size=7, ax=None):
      """
      Streamlined display of images using matplotlib.
  
      Parameters
      ----------
      img : ndarray, 2D or 3D
          The image to display
  
      cmap : str or Colormap, optional, default = 'gray'
          A colormap to use, for non RGB images
  
      bar : boolean, optional, default = False
          Whether to append a colorbar
  
      nans : boolean, optional, deafult = True
          Whether to replace NaNs, if True, will replace with 0s
  
      clim : tuple, optional, default = None
          Limits for scaling image
  
      size : scalar, optional, deafult = 9
          Size of the figure
  
      ax : matplotlib axis, optional, default = None
          An existing axis to plot into
      """
      from matplotlib.pyplot import axis, colorbar, figure, gca
  
      img = asarray(img)
  
      if (nans is True) and (img.dtype != bool):
          img = nan_to_num(img)
  
      if ax is None:
          f = figure(figsize=(size, size))
          ax = gca()
  
      if img.ndim == 3:
          if bar:
              raise ValueError("Cannot show meaningful colorbar for RGB images")
          if img.shape[2] != 3:
              raise ValueError("Size of third dimension must be 3 for RGB images, got %g" % img.shape[2])
          mn = img.min()
          mx = img.max()
          if mn < 0.0 or mx > 1.0:
              raise ValueError("Values must be between 0.0 and 1.0 for RGB images, got range (%g, %g)" % (mn, mx))
          im = ax.imshow(img, interpolation='nearest', clim=clim)
      else:
          im = ax.imshow(img, cmap=cmap, interpolation='nearest', clim=clim)
  
      if bar is True:
          cb = colorbar(im, fraction=0.046, pad=0.04)
          rng = abs(cb.vmax - cb.vmin) * 0.05
          cb.set_ticks([around(cb.vmin + rng, 1), around(cb.vmax - rng, 1)])
          cb.outline.set_visible(False)
  
      axis('off')
  
      return im