Based on this comment #391 (comment)
There is a repeated pattern of checking for function-specific imports and providing a helpful error message on failure to import, e.g.:
|
try: |
|
import sparse |
|
except ImportError: # pragma: no cover (import) |
|
raise ImportError("sparse is required to import from pydata sparse") from None |
|
if not isinstance(s, sparse.SparseArray): |
|
raise TypeError( |
|
"from_pydata_sparse only accepts objects from the `sparse` library; " |
|
"see https://sparse.pydata.org" |
|
) |
This issue is to study the feasibility and value-added of extracting this logic into a separate utility function.
Based on this comment #391 (comment)
There is a repeated pattern of checking for function-specific imports and providing a helpful error message on failure to import, e.g.:
python-graphblas/graphblas/io.py
Lines 246 to 254 in 7bf394d
This issue is to study the feasibility and value-added of extracting this logic into a separate utility function.