MCPcopy Create free account
hub / github.com/dask/dask / _is_sparse_container

Function _is_sparse_container

dask/array/utils.py:445–457  ·  view source on GitHub ↗

Whether ``obj`` is a SciPy or CuPy sparse container. Both the sparse matrix (``*_matrix``) and the sparse array (``*_array``) families are recognized. The check is done on the type's module so that it also covers formats whose concrete class lives in a submodule, e.g. ``scipy.sparse

(obj)

Source from the content-addressed store, hash-verified

443
444
445def _is_sparse_container(obj) -> bool:
446 """Whether ``obj`` is a SciPy or CuPy sparse container.
447
448 Both the sparse matrix (``*_matrix``) and the sparse array (``*_array``)
449 families are recognized. The check is done on the type's module so that it
450 also covers formats whose concrete class lives in a submodule, e.g.
451 ``scipy.sparse._csr.csr_array``.
452 """
453 module = type(obj).__module__
454 return any(
455 module == prefix or module.startswith(f"{prefix}.")
456 for prefix in _SPARSE_CONTAINER_MODULES
457 )
458
459
460def _array_like_safe(np_func, da_func, a, like, **kwargs):

Callers 1

_array_like_safeFunction · 0.85

Calls 1

anyFunction · 0.85

Tested by

no test coverage detected