docs: def log_of_array_ignoring_zeros(M):
      """Returns an array containing the logs of the nonzero
      elements of M. Zeros are left alone since log(0) isn't
      defined.
  
      Parameters
      ----------
      M : array-like
  
      Returns
      -------
      array-like
          Shape matches `M`
  
      """
      log_M = M.copy()
      mask = log_M > 0
      log_M[mask] = np.log(log_M[mask])
      return log_M