fast_array_utils.conv#

Conversion utilities.

fast_array_utils.conv.to_dense(x: CpuArray | DiskArray | sparray | spmatrix | CSRDataset | CSCDataset, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: bool = False) → NDArray[Any]#
fast_array_utils.conv.to_dense(x: Array, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: Literal[False] = False) → Array
fast_array_utils.conv.to_dense(x: Array, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: Literal[True]) → NDArray[Any]
fast_array_utils.conv.to_dense(x: GpuArray | spmatrix, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: Literal[False] = False) → ndarray
fast_array_utils.conv.to_dense(x: GpuArray | spmatrix, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: Literal[True]) → NDArray[Any]
fast_array_utils.conv.to_dense(x: A, /, *, order: Literal['K', 'A', 'C', 'F'] = 'K', to_cpu_memory: Literal[False] = False) → A
fast_array_utils.conv.to_dense(x: A, /, *, 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: spmatrix | 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