SparseArray
Represents a generic sparse array format which can be subclassed to provide a concrete implementation
backends: NoneType
cacheing_manager: cacheing_manager
initializer_list: initializer_list
get_backends():
Provides the set of backends to try by default
:returns
:_
from_data(data, shape=None, dtype=None, target_backend=None, constructor=None, **kwargs):
A wrapper so that we can dispatch to the best sparse backend we’ve got defined. Can be monkey patched.
data
:Any
kwargs
:Any
:returns
:SparseArray
from_diag(data, shape=None, dtype=None, **kwargs):
A wrapper so that we can dispatch to the best sparse backend we’ve got defined. Can be monkey patched.
data
:Any
kwargs
:Any
:returns
:_
from_diagonal_data(diags, **kw):
Constructs a sparse tensor from diagonal elements
diags
:Any
kw
:Any
:returns
:_
@property
shape(self):
Provides the shape of the sparse array
:returns
:tuple[int]
@property
ndim(self):
Provides the number of dimensions in the array
: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):
Loads from the stored state
serializer
:Any
:returns
:_
empty(shape, dtype=None, **kw):
initialize_empty(shp, shape=None, **kw):
Returns an empty SparseArray with the appropriate shape and dtype
shape
:Any
dtype
:Any
kw
:Any
:returns
:_
@property
block_data(self):
Returns the vector of values and corresponding indices
:returns
:_
@property
block_inds(self):
Returns indices for the stored values
:returns
:_
transpose(self, axes):
Returns a transposed version of the tensor
axes
:Any
:returns
:_
ascoo(self):
Converts the tensor into a scipy COO matrix…
:returns
:sp.coo_matrix
ascsr(self):
Converts the tensor into a scipy CSR matrix…
:returns
:sp.csr_matrix
asarray(self):
Converts the tensor into a dense np.ndarray
:returns
:np.ndarray
reshape(self, newshape):
Returns a reshaped version of the tensor
axes
:Any
:returns
:_
resize(self, newsize):
Returns a resized version of the tensor
axes
:Any
:returns
:_
pad_right(self, newshape):
Returns a right-padded version of the tensor
axes
:Any
:returns
:_
broadcast_to(self, shape) -> 'SparseArray':
Returns a broadcasted version of the tensor
axes
:Any
:returns
:_
expand_and_broadcast_to(self, expansion, new_shape) -> 'SparseArray':
Expands, then broadcasts (memory efficient)
axes
:Any
:returns
:_
expand_and_pad(self, expansion, padding) -> 'SparseArray':
Expands, then pads (memory efficient)
axes
:Any
:returns
:_
get_expanded_shape(shape, axis):
adapted from np.expand_dims
axis
:Any
:returns
:_
expand_dims(self, axis):
adapted from np.expand_dims
axis
:Any
:returns
:_
moveaxis(self, start, end):
Adapted from np.moveaxis
start
:Any
end
:Any
:returns
:_
concatenate(self, *others, axis=0):
Concatenates multiple SparseArrays along the specified axis
:returns
:SparseArray
__truediv__(self, other):
__rtruediv__(self, other):
__rmul__(self, other):
__mul__(self, other):
true_multiply(self, other):
Multiplies self and other
other
:Any
:returns
:SparseArray
multiply(self, other):
Multiplies self and other but allows for broadcasting
other
:SparseArray | np.ndarray | int | float
:returns
:_
dot(self, other):
Takes a regular dot product of self and other
other
:Any
axes
:Any
:returns
:_
outer(self, other):
Takes a tensor outer product of self and other
other
:Any
axes
:Any
:returns
:_
tensordot(self, other, axes=2):
Takes the dot product of self and other along the specified axes
other
:Any
axes
:Iterable[int] | Iterable[Iterable[int]]
the axes to contract along
:returns
:_
cache_options(enabled=True, clear=False):
get_caching_status():
A method to be overloaded. Subclasses may want to cache things for performance, so we provide a way for them to specify if caching is on or not
:returns
:_
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():
A method to be overloaded. Subclasses may want to cache things for performance, so we provide a way for them to clear this out.
:returns
:_