pybaselines._compat

Module Contents

Functions

csr_object

Handles creation of a sparse csr object.

dia_object

Handles creation of a sparse diagonal object.

diags

Handles creation of a sparse diagonal matrix.

identity

Handles creation of a sparse square identity matrix.

pybaselines._compat.csr_object(*args, **kwargs)[source]

Handles creation of a sparse csr object.

Parameters:
*args

Any arguments to pass to the creation functions.

**kwargs

Additional keyword arguments to pass to the creation functions.

Returns:
scipy.sparse.csr_matrix or scipy.sparse.csr_array

A sparse csr matrix if the intalled scipy version is older than 1.12, otherwise a sparse csr array.

pybaselines._compat.dia_object(*args, **kwargs)[source]

Handles creation of a sparse diagonal object.

Parameters:
*args

Any arguments to pass to the creation functions.

**kwargs

Additional keyword arguments to pass to the creation functions.

Returns:
scipy.sparse.dia_matrix or scipy.sparse.dia_array

A sparse diagonal matrix if the intalled scipy version is older than 1.12, otherwise a sparse diagonal array.

pybaselines._compat.diags(data, offsets=0, **kwargs)[source]

Handles creation of a sparse diagonal matrix.

Parameters:
dataarray-like

The data to be put in the diagonals.

offsetsint or Sequence[int], optional

The offsets for data. Default is 0, which is the main diagonal.

**kwargs

Additional keyword arguments to pass to the creation functions.

Returns:
scipy.sparse.spmatrix or scipy.sparse._sparray

The sparse identiy matrix.

Notes

This function will need to be updated in the future to prefer sparse.diags again once the sparse matrices are removed.

pybaselines._compat.identity(size, format=None, **kwargs)[source]

Handles creation of a sparse square identity matrix.

Parameters:
sizeint

The length of the rows and columns of the sparse matrix.

formatstr, optional

The sparse format to use for the identiy matrix. Default is None, which will use the default of the underlying functions.

**kwargs

Additional keyword arguments to pass to the creation functions.

Returns:
scipy.sparse.spmatrix or scipy.sparse._sparray

The sparse identity matrix.

Notes

This function will need to be updated in the future to prefer sparse.identity again once the sparse matrices are removed.