lenskit.data.matrix.SparseRowArray ================================== .. py:class:: lenskit.data.matrix.SparseRowArray Bases: :py:obj:`pyarrow.ExtensionArray` An array of sparse rows (a compressed sparse row matrix). .. stability:: internal .. py:attribute:: type :type: SparseRowType | SparseIndexListType .. py:method:: from_arrays(offsets, indices, values = None, *, shape = None) :classmethod: .. py:method:: from_array(array, dimension = None) :classmethod: Interpret an Arrow array as a sparse row array, if possible. Handles legacy layouts without the extension types. :param array: The array to convert. :param dimension: The dimensionality of the sparse rows, if known from an external source. .. py:method:: from_scipy(matrix, *, values = True, large = None) :classmethod: Create a sparse row array from a SciPy sparse matrix. :param csr: The SciPy sparse matrix (in CSR format). :param values: Whether to include the values or create a structure-only array. :param large: ``True`` to force creation of a :class:`pa.LargeListArray`. :returns: The sparse row array. .. py:method:: to_scipy() Convert this sparse row array to a SciPy sparse array. .. py:method:: to_torch() Convert this sparse row array to a Torch sparse tensor. .. py:method:: to_coo() Convert this array to table representing the array in COO format. .. py:property:: dimension :type: int Get the number of columns in the sparse matrix. .. py:property:: shape :type: tuple[int, int] .. py:property:: has_values :type: bool .. py:property:: offsets :type: pyarrow.Int32Array .. py:property:: indices :type: pyarrow.Int32Array .. py:property:: values :type: pyarrow.Array | None .. py:property:: nnz :type: int .. py:method:: structure() Get the structure of this matrix (without values). .. py:method:: transpose() Get the transpose of this sparse matrix. .. py:method:: row_extent(row) Get the start and end of a row. .. py:method:: row_indices(row) Get the index array for a compressed sparse row.