src.array.sparse package

Submodules

src.array.sparse.csr module

class src.array.sparse.csr.CsrArray(values_like, index_like, /, *, shape, dtype=None, copy_values=False, copy_index=False)

Bases: Generic[Data], SparseArray[Data]

Parameters:
  • values_like (Any)

  • index_like (Sequence[Any])

  • shape (Sequence[int])

  • dtype (Optional[type])

  • copy_values (bool)

  • copy_index (bool)

static as_array(values_like, index_like, /, *, shape=None, dtype=None, copy_values=False, copy_index=False)
Parameters:
  • values_like (Any)

  • index_like (Sequence[Any])

  • shape (Sequence[int] | None)

  • dtype (type | None)

  • copy_values (bool)

  • copy_index (bool)

Return type:

CsrArray[Data]

as_csr(copy_values=True, copy_index=True)
Parameters:
  • copy_values (bool)

  • copy_index (bool)

Return type:

Self

as_nparray()
Return type:

ndarray

static broadcast_to(*, shape)
Parameters:

shape (int | Sequence[int])

Return type:

NoReturn

compress(*, keep, axis=0)
Parameters:
  • keep (Any | Sequence[Any])

  • axis (int | Sequence[int] | None)

Return type:

CsrArray[Data]

compress_axis(*, keep, axis=0)
Parameters:
  • keep (Any)

  • axis (int | None)

Return type:

CsrArray[Data]

static concat(arrs, /, *, axis=0)
Parameters:
  • arrs (Sequence[CsrArray[Data]])

  • axis (int)

Return type:

CsrArray[Data]

count_nonzero(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

diagonal()
Return type:

BaseArray[Data]

static expand_dims(*, axis)
Parameters:

axis (int | Sequence[int])

Return type:

NoReturn

fill_diagonal(other)
Parameters:

other (Any)

Return type:

CsrArray[Data]

get_dense_index()
Return type:

tuple[Storage[Data], Storage[Data]]

property indices: Storage[Data]
property indptr: Storage[Data]
static mask_as_csr_index(mask_like)
Parameters:

mask_like (Any)

Return type:

tuple[Storage[Data], Storage[Data], tuple[int, int]]

max(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

mean(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

min(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

property ncols: int
property nrows: int
static reshape(*, shape)
Parameters:

shape (int | Sequence[int])

Return type:

NoReturn

property shape: tuple[int, int]
static squeeze(*, axis)
Parameters:

axis (int | Sequence[int])

Return type:

NoReturn

static stack(arrs, /, *, axis=0)
Parameters:
  • arrs (Sequence[CsrArray[Data]])

  • axis (int)

Return type:

NoReturn

sum(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

src.array.sparse.sparse module

class src.array.sparse.sparse.SparseArray(values_like, index_like, /, *, shape, dtype=None, copy_values=False, copy_index=False, **kwargs)

Bases: Generic[Data], BaseArray[Data]

Parameters:
  • values_like (Any)

  • index_like (Sequence[Any])

  • shape (Sequence[int])

  • dtype (Optional[type])

  • copy_values (bool)

  • copy_index (bool)

  • kwargs (Any)

as_dense(fill_value)
Parameters:

fill_value (Any)

Return type:

DenseArray[Data]

as_type(*, dtype, copy_values=False, copy_index=False)
Parameters:
  • dtype (type)

  • copy_values (bool)

  • copy_index (bool)

Return type:

Self

copy(copy_values=True, copy_index=True)
Parameters:
  • copy_values (bool)

  • copy_index (bool)

Return type:

Self

cos(copy_index=False)
Parameters:
Return type:

SparseArray[Data]

exp(copy_index=False)
Parameters:
Return type:

SparseArray[Data]

abstractmethod get_dense_index()
Return type:

tuple[Storage[Data], …]

icos()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

iexp()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

ilog()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

property index: tuple[Storage[Data], ...]
isin()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

isqrt()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

log(copy_index=False)
Parameters:
Return type:

SparseArray[Data]

property shape: tuple[int, ...]
sin(copy_index=False)
Parameters:
Return type:

SparseArray[Data]

property sparsity: float
sqrt(copy_index=False)
Parameters:
Return type:

SparseArray[Data]

Module contents

class src.array.sparse.CsrArray(values_like, index_like, /, *, shape, dtype=None, copy_values=False, copy_index=False)

Bases: Generic[Data], SparseArray[Data]

Parameters:
  • values_like (Any)

  • index_like (Sequence[Any])

  • shape (Sequence[int])

  • dtype (Optional[type])

  • copy_values (bool)

  • copy_index (bool)

static as_array(values_like, index_like, /, *, shape=None, dtype=None, copy_values=False, copy_index=False)
Parameters:
  • values_like (Any)

  • index_like (Sequence[Any])

  • shape (Sequence[int] | None)

  • dtype (type | None)

  • copy_values (bool)

  • copy_index (bool)

Return type:

CsrArray[Data]

as_csr(copy_values=True, copy_index=True)
Parameters:
  • copy_values (bool)

  • copy_index (bool)

Return type:

Self

as_nparray()
Return type:

ndarray

static broadcast_to(*, shape)
Parameters:

shape (int | Sequence[int])

Return type:

NoReturn

compress(*, keep, axis=0)
Parameters:
  • keep (Any | Sequence[Any])

  • axis (int | Sequence[int] | None)

Return type:

CsrArray[Data]

compress_axis(*, keep, axis=0)
Parameters:
  • keep (Any)

  • axis (int | None)

Return type:

CsrArray[Data]

static concat(arrs, /, *, axis=0)
Parameters:
  • arrs (Sequence[CsrArray[Data]])

  • axis (int)

Return type:

CsrArray[Data]

count_nonzero(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

diagonal()
Return type:

BaseArray[Data]

static expand_dims(*, axis)
Parameters:

axis (int | Sequence[int])

Return type:

NoReturn

fill_diagonal(other)
Parameters:

other (Any)

Return type:

CsrArray[Data]

get_dense_index()
Return type:

tuple[Storage[Data], Storage[Data]]

property indices: Storage[Data]
property indptr: Storage[Data]
static mask_as_csr_index(mask_like)
Parameters:

mask_like (Any)

Return type:

tuple[Storage[Data], Storage[Data], tuple[int, int]]

max(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

mean(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

min(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

property ncols: int
property nrows: int
static reshape(*, shape)
Parameters:

shape (int | Sequence[int])

Return type:

NoReturn

property shape: tuple[int, int]
static squeeze(*, axis)
Parameters:

axis (int | Sequence[int])

Return type:

NoReturn

static stack(arrs, /, *, axis=0)
Parameters:
  • arrs (Sequence[CsrArray[Data]])

  • axis (int)

Return type:

NoReturn

sum(*, axis=None, keepdims=False)
Parameters:
  • axis (int | Sequence[int] | None)

  • keepdims (bool)

Return type:

DenseArray[Data]

class src.array.sparse.SparseArray(values_like, index_like, /, *, shape, dtype=None, copy_values=False, copy_index=False, **kwargs)

Bases: Generic[Data], BaseArray[Data]

Parameters:
  • values_like (Any)

  • index_like (Sequence[Any])

  • shape (Sequence[int])

  • dtype (Optional[type])

  • copy_values (bool)

  • copy_index (bool)

  • kwargs (Any)

as_dense(fill_value)
Parameters:

fill_value (Any)

Return type:

DenseArray[Data]

as_type(*, dtype, copy_values=False, copy_index=False)
Parameters:
  • dtype (type)

  • copy_values (bool)

  • copy_index (bool)

Return type:

Self

copy(copy_values=True, copy_index=True)
Parameters:
  • copy_values (bool)

  • copy_index (bool)

Return type:

Self

cos(copy_index=False)
Parameters:
Return type:

SparseArray[Data]

exp(copy_index=False)
Parameters:
Return type:

SparseArray[Data]

abstractmethod get_dense_index()
Return type:

tuple[Storage[Data], …]

icos()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

iexp()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

ilog()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

property index: tuple[Storage[Data], ...]
isin()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

isqrt()
Parameters:

self (SparseArray[Data])

Return type:

SparseArray[Data]

log(copy_index=False)
Parameters:
Return type:

SparseArray[Data]

property shape: tuple[int, ...]
sin(copy_index=False)
Parameters:
Return type:

SparseArray[Data]

property sparsity: float
sqrt(copy_index=False)
Parameters:
Return type:

SparseArray[Data]