lenskit.data.matrix.SparseRowType#

class lenskit.data.matrix.SparseRowType(dimension, value_type=pa.float32(), large=False)#

Bases: pyarrow.ExtensionType

Data type for sparse rows stored in Arrow. Sparse rows are stored as lists of structs with index and column 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:
value_type: pyarrow.DataType | None#
index_type: SparseIndexType#
classmethod from_type(data_type, dimension=None)#

Create a sparse row type from an Arrow data type, handling legacy struct layouts without the extension types.

Parameters:
  • data_type (pyarrow.DataType) – The Arrow data type to interpret as a row type.

  • dimension (int | None) – The row dimension, if known from an external source. If provided and the data type also includes the dimensionality, both dimensions must match.

Raises:
  • TypeError – If the data type is not a valid sparse row type.

  • ValueError – If there is another error, such as mismatched dimensions.

Return type:

SparseRowType

property dimension: int#
Return type:

int

__arrow_ext_serialize__()#
Return type:

bytes

classmethod __arrow_ext_deserialize__(storage_type, serialized)#
__arrow_ext_class__()#