Last active
September 26, 2018 03:24
-
-
Save chelseatroy/9193230843186dcf062316f82b49eee1 to your computer and use it in GitHub Desktop.
cs_matrix initializer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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