GCXS

class sparse.GCXS(arg, shape=None, compressed_axes=None, prune=False, fill_value=0)[source]

A sparse multidimensional array.

This is stored in GCXS format, a generalization of the GCRS/GCCS formats from ‘Efficient storage scheme for n-dimensional sparse array: GCRS/GCCS’: https://ieeexplore.ieee.org/document/7237032. GCXS generalizes the csr/csc sparse matrix formats. For arrays with ndim == 2, GCXS is the same csr/csc. For arrays with ndim >2, any combination of axes can be compressed, significantly reducing storage.

Parameters
  • arg (tuple (data, indices, indptr)) – A tuple of arrays holding the data, indices, and index pointers for the nonzero values of the array.

  • shape (tuple[int] (COO.ndim,)) – The shape of the array.

  • compressed_axes (Iterable[int]) – The axes to compress.

  • prune (bool, optional) – A flag indicating whether or not we should prune any fill-values present in the data array.

  • fill_value (scalar, optional) – The fill value for this array.

data

An array holding the nonzero values corresponding to GCXS.indices.

Type

numpy.ndarray (nnz,)

indices

An array holding the coordinates of every nonzero element along uncompressed dimensions.

Type

numpy.ndarray (nnz,)

indptr

An array holding the cumulative sums of the nonzeros along the compressed dimensions.

Type

numpy.ndarray

shape

The dimensions of this array.

Type

tuple[int] (ndim,)

See also

DOK

A mostly write-only sparse array.

Attributes

GCXS.T

GCXS.density

The ratio of nonzero to all elements in this array.

GCXS.dtype

The datatype of this array.

GCXS.imag

The imaginary part of the array.

GCXS.nbytes

The number of bytes taken up by this object.

GCXS.ndim

The number of dimensions of this array.

GCXS.nnz

The number of nonzero elements in this array.

GCXS.real

The real part of the array.

GCXS.size

The number of all elements (including zeros) in this array.

Methods

GCXS.__init__(arg[, shape, compressed_axes, …])

Initialize self.

GCXS.all([axis, keepdims, out])

See if all values in an array are True.

GCXS.amax([axis, keepdims, out])

Maximize along the given axes.

GCXS.amin([axis, keepdims, out])

Minimize along the given axes.

GCXS.any([axis, keepdims, out])

See if any values along array are True.

GCXS.asformat(format[, compressed_axes])

Convert this sparse array to a given format.

GCXS.astype(dtype[, casting, copy])

Copy of the array, cast to a specified type.

GCXS.change_compressed_axes(new_compressed_axes)

Returns a new array with specified compressed axes.

GCXS.clip([min, max, out])

Clip (limit) the values in the array.

GCXS.conj()

Return the complex conjugate, element-wise.

GCXS.copy([deep])

Return a copy of the array.

GCXS.dot(other)

Performs the equivalent of x.dot(y) for GCXS.

GCXS.flatten([order])

Returns a new GCXS array that is a flattened version of this array.

GCXS.from_coo(x[, compressed_axes])

GCXS.from_iter(x[, shape, compressed_axes, …])

GCXS.from_numpy(x[, compressed_axes, fill_value])

GCXS.from_scipy_sparse(x)

GCXS.max([axis, keepdims, out])

Maximize along the given axes.

GCXS.maybe_densify([max_size, min_density])

Converts this GCXS array to a numpy.ndarray if not too costly.

GCXS.mean([axis, keepdims, dtype, out])

Compute the mean along the given axes.

GCXS.min([axis, keepdims, out])

Minimize along the given axes.

GCXS.prod([axis, keepdims, dtype, out])

Performs a product operation along the given axes.

GCXS.reduce(method[, axis, keepdims])

Performs a reduction operation on this array.

GCXS.reshape(shape[, order, compressed_axes])

Returns a new GCXS array that is a reshaped version of this array.

GCXS.resize(*args[, refcheck, compressed_axes])

This method changes the shape and size of an array in-place.

GCXS.round([decimals, out])

Evenly round to the given number of decimals.

GCXS.round_([decimals, out])

Evenly round to the given number of decimals.

GCXS.std([axis, dtype, out, ddof, keepdims])

Compute the standard deviation along the given axes.

GCXS.sum([axis, keepdims, dtype, out])

Performs a sum operation along the given axes.

GCXS.to_scipy_sparse()

Converts this GCXS object into a scipy.sparse.csr_matrix or scipy.sparse.csc_matrix.

GCXS.tocoo()

Convert this GCXS array to a COO.

GCXS.todense()

Convert this GCXS array to a dense numpy.ndarray.

GCXS.todok()

GCXS.transpose([axes, compressed_axes])

Returns a new array which has the order of the axes switched.

GCXS.var([axis, dtype, out, ddof, keepdims])

Compute the variance along the gi66ven axes.