sparse.data

Base class for sparse matrice with a .data attribute

subclasses must provide a _with_data() method that creates a new matrix with the same sparsity pattern as self but with a different data array

Module Contents

Classes

_data_matrix(self)
_minmax_mixin() Mixin for min and max methods.

Functions

_create_method(op)
_find_missing_index(ind,n)
class _data_matrix
__init__()
_get_dtype()
_set_dtype(newtype)
_deduped_data()
__abs__()
_real()
_imag()
__neg__()
__imul__(other)
__itruediv__(other)
astype(dtype, casting="unsafe", copy=True)
conj()
copy()
count_nonzero()
power(n, dtype=None)

This function performs element-wise power.

n : n is a scalar

dtype : If dtype is not specified, the current dtype will be preserved.

_mul_scalar(other)
_create_method(op)
_find_missing_index(ind, n)
class _minmax_mixin

Mixin for min and max methods.

These are not implemented for dia_matrix, hence the separate class.

_min_or_max_axis(axis, min_or_max)
_min_or_max(axis, out, min_or_max)
_arg_min_or_max_axis(axis, op, compare)
_arg_min_or_max(axis, out, op, compare)
max(axis=None, out=None)

Return the maximum of the matrix or maximum along an axis. This takes all elements into account, not just the non-zero ones.

axis : {-2, -1, 0, 1, None} optional
Axis along which the sum is computed. The default is to compute the maximum over all the matrix elements, returning a scalar (i.e. axis = None).
out : None, optional
This argument is in the signature solely for NumPy compatibility reasons. Do not pass in anything except for the default value, as this argument is not used.
amax : coo_matrix or scalar
Maximum of a. If axis is None, the result is a scalar value. If axis is given, the result is a sparse.coo_matrix of dimension a.ndim - 1.

min : The minimum value of a sparse matrix along a given axis. np.matrix.max : NumPy’s implementation of ‘max’ for matrices

min(axis=None, out=None)

Return the minimum of the matrix or maximum along an axis. This takes all elements into account, not just the non-zero ones.

axis : {-2, -1, 0, 1, None} optional
Axis along which the sum is computed. The default is to compute the minimum over all the matrix elements, returning a scalar (i.e. axis = None).
out : None, optional
This argument is in the signature solely for NumPy compatibility reasons. Do not pass in anything except for the default value, as this argument is not used.
amin : coo_matrix or scalar
Minimum of a. If axis is None, the result is a scalar value. If axis is given, the result is a sparse.coo_matrix of dimension a.ndim - 1.

max : The maximum value of a sparse matrix along a given axis. np.matrix.min : NumPy’s implementation of ‘min’ for matrices

argmax(axis=None, out=None)

Return indices of maximum elements along an axis.

Implicit zero elements are also taken into account. If there are several maximum values, the index of the first occurrence is returned.

axis : {-2, -1, 0, 1, None}, optional
Axis along which the argmax is computed. If None (default), index of the maximum element in the flatten data is returned.
out : None, optional
This argument is in the signature solely for NumPy compatibility reasons. Do not pass in anything except for the default value, as this argument is not used.
ind : np.matrix or int
Indices of maximum elements. If matrix, its size along axis is 1.
argmin(axis=None, out=None)

Return indices of minimum elements along an axis.

Implicit zero elements are also taken into account. If there are several minimum values, the index of the first occurrence is returned.

axis : {-2, -1, 0, 1, None}, optional
Axis along which the argmin is computed. If None (default), index of the minimum element in the flatten data is returned.
out : None, optional
This argument is in the signature solely for NumPy compatibility reasons. Do not pass in anything except for the default value, as this argument is not used.
ind : np.matrix or int
Indices of minimum elements. If matrix, its size along axis is 1.