Commit 9d4fae0b authored by rusty1s's avatar rusty1s
Browse files

allow empty storage

parent 6f6c9285
...@@ -155,6 +155,19 @@ class SparseStorage(object): ...@@ -155,6 +155,19 @@ class SparseStorage(object):
self._csr2csc = None self._csr2csc = None
self._csc2csr = None self._csc2csr = None
@classmethod
def empty(self):
self = SparseStorage.__new__(SparseStorage)
self._row = None
self._rowptr = None
self._value = None
self._rowcount = None
self._colptr = None
self._colcount = None
self._csr2csc = None
self._csc2csr = None
return self
def has_row(self) -> bool: def has_row(self) -> bool:
return self._row is not None return self._row is not None
...@@ -605,19 +618,3 @@ def is_shared(self) -> bool: ...@@ -605,19 +618,3 @@ def is_shared(self) -> bool:
SparseStorage.share_memory_ = share_memory_ SparseStorage.share_memory_ = share_memory_
SparseStorage.is_shared = is_shared SparseStorage.is_shared = is_shared
def __new__(cls, *args, **kwargs):
instance = super(SparseStorage, cls).__new__(cls, *args, **kwargs)
instance._row = None
instance._rowptr = None
instance._value = None
instance._rowcount = None
instance._colptr = None
instance._colcount = None
instance._csr2csc = None
instance._csc2csr = None
return instance
SparseStorage.__new__ = __new__
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment