Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active September 26, 2018 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/9193230843186dcf062316f82b49eee1 to your computer and use it in GitHub Desktop.
Save chelseatroy/9193230843186dcf062316f82b49eee1 to your computer and use it in GitHub Desktop.
cs_matrix initializer
class _cs_matrix(_data_matrix, _minmax_mixin, IndexMixin):
"""base matrix class for compressed row and column oriented matrices"""
def __init__(self, arg1, shape=None, dtype=None, copy=False):
_data_matrix.__init__(self)
if isspmatrix(arg1):
...
elif isinstance(arg1, tuple):
...
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:
...
self.check_format(full_check=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment