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 __init__(self, arg1, shape=None, dtype=None, copy=False):
      _data_matrix.__init__(self)
  
      if isspmatrix(arg1):
          if arg1.format == self.format and copy:
              arg1 = arg1.copy()
          else:
              arg1 = arg1.asformat(self.format)
          self._set_self(arg1)
  
      elif isinstance(arg1, tuple):
          if isshape(arg1):
              # It's a tuple of matrix dimensions (M, N)
              # create empty matrix
              self._shape = check_shape(arg1)
              M, N = self.shape
              # Select index dtype large enough to pass array and
              # scalar parameters to sparsetools
              idx_dtype = get_index_dtype(maxval=max(M, N))
              self.data = np.zeros(0, getdtype(dtype, default=float))
              self.indices = np.zeros(0, idx_dtype)
              self.indptr = np.zeros(
                  self._swap((M, N))[0] + 1, dtype=idx_dtype
              )
          else:
              if len(arg1) == 2:
                  # (data, ij) format
                  from .coo import coo_matrix
  
                  other = self.__class__(coo_matrix(arg1, shape=shape))
                  self._set_self(other)
              elif len(arg1) == 3:
                  # (data, indices, indptr) format
                  (data, indices, indptr) = arg1
  
                  # Select index dtype large enough to pass array and
                  # scalar parameters to sparsetools
                  maxval = None
                  if shape is not None:
                      maxval = max(shape)
                  idx_dtype = get_index_dtype(
                      (indices, indptr),
                      maxval=maxval,
                      check_contents=True,
                  )
  
                  self.indices = np.array(
                      indices, copy=copy, dtype=idx_dtype
                  )
                  self.indptr = np.array(
                      indptr, copy=copy, dtype=idx_dtype
                  )
                  self.data = np.array(data, copy=copy, dtype=dtype)
              else:
                  raise ValueError(
                      "unrecognized {}_matrix "
                      "constructor usage".format(self.format)
                  )
  
      else:
          # must be dense
          try:
              arg1 = np.asarray(arg1)
          except Exception:
              raise ValueError(
                  "unrecognized {}_matrix constructor usage"
                  "".format(self.format)
              )
          from .coo import coo_matrix
  
          self._set_self(self.__class__(coo_matrix(arg1, dtype=dtype)))
  
      # Read matrix dimensions given, if any
      if shape is not None:
          self._shape = check_shape(shape)
      else:
          if self.shape is None:
              # shape not already set, try to infer dimensions
              try:
                  major_dim = len(self.indptr) - 1
                  minor_dim = self.indices.max() + 1
              except Exception:
                  raise ValueError("unable to infer matrix dimensions")
              else:
                  self._shape = check_shape(
                      self._swap((major_dim, minor_dim))
                  )
  
      if dtype is not None:
          self.data = np.asarray(self.data, dtype=dtype)
  
      self.check_format(full_check=False)
  
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 1 to create a new _cs_matrix object from inherited base classes: _data_matrix, _minmax_mixin, IndexMixin with example: obj = _cs_matrix(arg1, shape, dtype, copy)