class_docstr: base matrix class for compressed row and column oriented matrices
class_docstr_tok: ["base","matrix","class","for","compressed","row","and","column","oriented","matrices"]
code: def _setdiag(self, values, k):
      if 0 in self.shape:
          return
  
      M, N = self.shape
      broadcast = values.ndim == 0
  
      if k < 0:
          if broadcast:
              max_index = min(M + k, N)
          else:
              max_index = min(M + k, N, len(values))
          i = np.arange(max_index, dtype=self.indices.dtype)
          j = np.arange(max_index, dtype=self.indices.dtype)
          i -= k
  
      else:
          if broadcast:
              max_index = min(M, N - k)
          else:
              max_index = min(M, N - k, len(values))
          i = np.arange(max_index, dtype=self.indices.dtype)
          j = np.arange(max_index, dtype=self.indices.dtype)
          j += k
  
      if not broadcast:
          values = values[: len(i)]
  
      self[i, j] = values
  
imports: from __future__ import division, print_function, absolute_import
  from warnings import warn
  import operator
  import numpy
  from scipy._lib.six import zip
  from scipy._lib._util import _prune_array
  from .base import spmatrix, isspmatrix, SparseEfficiencyWarning
  from .data import _data_matrix, _minmax_mixin
  from .dia import dia_matrix
  from .None import _sparsetools
  from .sputils import upcast, upcast_char, to_native, isdense, isshape, getdtype, isscalarlike, IndexMixin, get_index_dtype, downcast_intp_index, get_sum_dtype, check_shape, matrix, asmatrix
label_desc: Use image node_id 27 for calling the _cs_matrix obj's underlying member method code with example usage: obj._setdiag(values, k) without return types