lenskit.data.matrix.SparseIndexType#
- class lenskit.data.matrix.SparseIndexType(dimension)#
Bases:
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)
- __init__(dimension)#
Initialize an extension type instance.
This should be called at the end of the subclass’
__init__
method.- Parameters:
dimension (int)
Methods
__init__
(dimension)Initialize an extension type instance.
check_dimension
(expected)Check that this index type has the expected dimension.
equals
(self, other, *[, check_metadata])Return true if type is equivalent to passed value.
field
(self, i)to_pandas_dtype
(self)Return the equivalent NumPy / Pandas dtype.
wrap_array
(self, storage)Wrap the given storage array as an extension array.
Attributes
bit_width
The bit width of the extension type.
byte_width
The byte width of the extension type.
extension_name
The extension type name.
has_variadic_buffers
If True, the number of expected buffers is only lower-bounded by num_buffers.
id
num_buffers
Number of data buffers required to construct Array type excluding children.
num_fields
The number of child fields.
storage_type
The underlying storage type.
dimension
- 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: