MCPcopy Create free account
hub / github.com/pydata/xarray / _is_scalar

Function _is_scalar

xarray/core/utils.py:369–382  ·  view source on GitHub ↗
(value, include_0d)

Source from the content-addressed store, hash-verified

367
368
369def _is_scalar(value, include_0d):
370 from xarray.core.variable import NON_NUMPY_SUPPORTED_ARRAY_TYPES
371
372 if include_0d:
373 include_0d = getattr(value, "ndim", None) == 0
374 return (
375 include_0d
376 or isinstance(value, str | bytes)
377 or not (
378 isinstance(value, (Iterable,) + NON_NUMPY_SUPPORTED_ARRAY_TYPES)
379 or hasattr(value, "__array_function__")
380 or hasattr(value, "__array_namespace__")
381 )
382 )
383
384
385def is_scalar(value: Any, include_0d: bool = True) -> TypeGuard[Hashable]:

Callers 1

is_scalarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…