DOK.from_numpy

classmethod DOK.from_numpy(x)[source]

Get a DOK array from a Numpy array.

Parameters

x (np.ndarray) – The array to convert.

Returns

The equivalent DOK array.

Return type

DOK

Examples

>>> s = DOK.from_numpy(np.eye(4))
>>> s
<DOK: shape=(4, 4), dtype=float64, nnz=4, fill_value=0.0>