fast_array_utils.conv

Conversion utilities.

fast_array_utils.conv.to_dense(x: CpuArray | DiskArray | types.sparray | types.spmatrix | types.CSDataset, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: bool = False) NDArray[Any]
fast_array_utils.conv.to_dense(x: types.DaskArray, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: Literal[False] = False) types.DaskArray
fast_array_utils.conv.to_dense(x: types.DaskArray, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: Literal[True]) NDArray[Any]
fast_array_utils.conv.to_dense(x: GpuArray | types.CupySpMatrix, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: Literal[False] = False) types.CupyArray
fast_array_utils.conv.to_dense(x: GpuArray | types.CupySpMatrix, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: Literal[True]) NDArray[Any]

Convert x to a dense array.

If to_cpu_memory is False, dask.array.Arrays and cupy.ndarrays/cupyx.scipy.sparse.spmatrix instances stay out-of-core and in GPU memory, respecively.

Parameters:
  • x – Input object to be converted.

  • order

    The order of the output array: C (row-major) or F (column-major). K and A derive the order from x.

    The default matches numpy, and therefore diverges from the scipy.sparse matrices’ toarray()’s default behavior of always returning a C-contiguous array. Instead, CSC matrices become F-contiguous arrays when order="K" (the default).

    Dask Arrays concatenation behavior will result in order having no effect on the dask.compute() / to_cpu_memory=True result.

  • to_cpu_memory – Also load data into memory (resulting in a numpy.ndarray).

Returns:

Dense form of x

fast_array_utils.conv.scipy

Utilities only for sparse matrices.

fast_array_utils.conv.scipy.to_dense(x: types.spmatrix | types.sparray, order: Literal['C', 'F'] = 'C') NDArray[Any]

Convert a sparse matrix to a dense matrix.

Parameters:
  • x – Input matrix.

  • order – The order of the output matrix.

Returns:

Dense matrix form of x