parameters: (v, k=0)
return_statement: return output
docstring: Extract a diagonal or construct a diagonal array.
  
      This function is the equivalent of `numpy.diag` that takes masked
      values into account, see `numpy.diag` for details.
  
      See Also
      --------
      numpy.diag : Equivalent function for ndarrays.
docstring_summary: Extract a diagonal or construct a diagonal array.
docstring_tokens: Extract a diagonal or construct a diagonal array .
function: def diag(v, k=0):
      """
      Extract a diagonal or construct a diagonal array.
  
      This function is the equivalent of `numpy.diag` that takes masked
      values into account, see `numpy.diag` for details.
  
      See Also
      --------
      numpy.diag : Equivalent function for ndarrays.
  
      """
      output = np.diag(v, k).view(MaskedArray)
      if getmask(v) is not nomask:
          output._mask = np.diag(v._mask, k)
      return output
function_tokens: def diag ( v , k = 0 ) : output = np . diag ( v , k ) . view ( MaskedArray ) if getmask ( v ) is not nomask : output . _mask = np . diag ( v . _mask , k ) return output