(value: Any)
| 76 | |
| 77 | |
| 78 | def is_duck_array(value: Any) -> TypeGuard[duckarray[Any, Any]]: |
| 79 | # TODO: replace is_duck_array with runtime checks via _arrayfunction_or_api protocol on |
| 80 | # python 3.12 and higher (see https://github.com/pydata/xarray/issues/8696#issuecomment-1924588981) |
| 81 | if isinstance(value, np.ndarray): |
| 82 | return True |
| 83 | return ( |
| 84 | hasattr(value, "ndim") |
| 85 | and hasattr(value, "shape") |
| 86 | and hasattr(value, "dtype") |
| 87 | and ( |
| 88 | (hasattr(value, "__array_function__") and hasattr(value, "__array_ufunc__")) |
| 89 | or hasattr(value, "__array_namespace__") |
| 90 | ) |
| 91 | ) |
| 92 | |
| 93 | |
| 94 | def is_duck_dask_array(x: duckarray[Any, Any]) -> TypeGuard[DaskArray]: |
no outgoing calls
no test coverage detected
searching dependent graphs…