lenskit.data.matrix.SparseIndexType#

class lenskit.data.matrix.SparseIndexType(dimension)#

Bases: pyarrow.ExtensionType

Data type for the index field of a sparse row. Indexes are just stored as ``int32``s; the extension type attaches the row’s dimensionality to the index field (making it easier to pass it to/from Rust, since we often pass arrays and not entire fields).

Stability: Internal

This API is at the internal or experimental stability level: it may change at any time, and breaking changes will not necessarily be described in the release notes. See Stability Levels for details.

Parameters:

dimension (int)

dimension: int#
check_dimension(expected)#

Check that this index type has the expected dimension.

Returns:

The dimension of the index type.

Raises:

ValueError – If the type’s dimension does not match the expected dimension.

Parameters:

expected (int | None)

Return type:

int

__arrow_ext_serialize__()#
Return type:

bytes

classmethod __arrow_ext_deserialize__(storage_type, serialized)#