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 resize(self, *shape):
      shape = check_shape(shape)
      if hasattr(self, "blocksize"):
          bm, bn = self.blocksize
          new_M, rm = divmod(shape[0], bm)
          new_N, rn = divmod(shape[1], bn)
          if rm or rn:
              raise ValueError(
                  "shape must be divisible into %s blocks. "
                  "Got %s" % (self.blocksize, shape)
              )
          M, N = self.shape[0] // bm, self.shape[1] // bn
      else:
          new_M, new_N = self._swap(shape)
          M, N = self._swap(self.shape)
  
      if new_M < M:
          self.indices = self.indices[: self.indptr[new_M]]
          self.data = self.data[: self.indptr[new_M]]
          self.indptr = self.indptr[: new_M + 1]
      elif new_M > M:
          self.indptr = np.resize(self.indptr, new_M + 1)
          self.indptr[M + 1 :].fill(self.indptr[M])
  
      if new_N < N:
          mask = self.indices < new_N
          if not np.all(mask):
              self.indices = self.indices[mask]
              self.data = self.data[mask]
              major_index, val = self._minor_reduce(np.add, mask)
              self.indptr.fill(0)
              self.indptr[1:][major_index] = val
              np.cumsum(self.indptr, out=self.indptr)
  
      self._shape = shape
  
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 45 for calling the _cs_matrix obj's underlying member method code with example usage: obj.resize() without return types