ScipySparseArray
Array class that generalize the regular scipy.sparse.spmatrix
.
Basically acts like a high-dimensional wrapper that manages the shape of a standard scipy.sparse_matrix
, since that is rigidly 2D.
We always use a combo of an underlying CSR or CSC matrix & COO-like shape operations.
formats_map: dict
default_cache_size: int
caching_enabled: bool
__init__(self, a, shape=None, layout=None, dtype=None, initialize=True, cache_block_data=None, logger=None, init_kwargs=None):
a
:Any
shape
:Any
layout
:Any
dtype
:Any
initialize
:Any
cache_block_data
:Any
whether or not
logger
:Logger
the logger to use for debug purposes
coo_to_cs(shape, vals, ij_inds, memmap=False, assume_sorted=False):
Reimplementation of scipy’s internal “coo_tocsr” for memory-limited situations
Assumes ij_inds
are sorted by row then column, which allows vals to be used
directly once indptr is computed
:returns
:_
to_state(self, serializer=None):
Provides just the state that is needed to serialize the object
serializer
:Any
:returns
:_
from_state(state, serializer=None):
initialize_empty(shape, dtype=None, layout=None, **kw):
construct_sparse_from_val_inds(a, shape, fmt, cache_block_data=True, logger=None, assume_sorted=False):
@property
dtype(self):
@property
diag(self):
from_diagonal_data(diags, shape=None, **kw):
asarray(self):
todense(self):
ascoo(self):
ascsr(self):
ascsc(self):
@property
data(self):
format_from_string(fmt):
@property
fmt(self):
@property
shape(self):
@property
ndim(self):
@property
non_zero_count(self):
get_caching_status():
enable_caches():
A method to be overloaded. Subclasses may want to cache things for performance, so we provide a way for them to turn this on
:returns
:_
disable_caches():
A method to be overloaded. Subclasses may want to cache things for performance, so we provide a way for them to turn this off
:returns
:_
clear_cache():
clear_ravel_caches():
set_ravel_cache_size(size):
find(self):
@property
block_vals(self):
@property
block_inds(self):
@property
block_data(self):
transpose(self, transp):
Transposes the array and returns a new one. Not necessarily a cheap operation.
transp
:Iterable[int]
the transposition to do
:returns
:_
reshape_internal(self, shp):
reshape(self, shp):
Had to make this op not in-place because otherwise got scary errors…
shp
:Any
:returns
:_
pad_right(self, amounts):
squeeze(self):
resize(self, newsize):
Returns a resized version of the tensor
newsize
:tuple[int]
:returns
:_
concatenate_coo(self, *others, axis=0):
concatenate_2d(self, *others, axis=0):
concatenate(self, *others, axis=0):
Concatenates multiple arrays along the specified axis This is relatively inefficient in terms of not tracking indices throughout
other
:Any
axis
:Any
:returns
:_
broadcast_values(new_shape, old_shape, vals, inds):
Implements broadcast_to using COO-style operations to be a little bit more efficient
shape
:Any
:returns
:_
broadcast_to(self, shape):
Broadcasts to shape
shape
:Any
:returns
:_
expand_and_broadcast_to(self, expansion, new_shape):
expand_and_pad(self, expansion, padding):
@property
T(self):
__matmul__(self, other):
ascs(self, inplace=False):
dot(self, b, reverse=False):
outer(self, other):
__neg__(self):
__pos__(self):
__add__(self, other):
__iadd__(self, other):
__radd__(self, other):
plus(self, other, inplace=False):
floopy_flop(self):
__truediv__(self, other):
__rtruediv__(self, other):
__rmul__(self, other):
__mul__(self, other):
true_multiply(self, other):
copy(self):
savez(self, file, compressed=True):
Saves a SparseArray to a file (must have the npz extension)
file
:Any
compressed
:Any
:returns
:str
t h e
s a v e d
f i l e
loadz(file):
Loads a SparseArray from an npz file
file
:Any
:returns
:SparseArray
__getitem__(self, item):
__setitem__(self, item, val):
__delitem__(self, item):
__repr__(self):