MCPcopy Index your code
hub / github.com/pydata/xarray / is_uniform_spaced

Function is_uniform_spaced

xarray/core/utils.py:799–811  ·  view source on GitHub ↗

Return True if values of an array are uniformly spaced and sorted. >>> is_uniform_spaced(range(5)) True >>> is_uniform_spaced([-4, 0, 100]) False kwargs are additional arguments to ``np.isclose``

(arr, **kwargs)

Source from the content-addressed store, hash-verified

797
798
799def is_uniform_spaced(arr, **kwargs) -> bool:
800 """Return True if values of an array are uniformly spaced and sorted.
801
802 >>> is_uniform_spaced(range(5))
803 True
804 >>> is_uniform_spaced([-4, 0, 100])
805 False
806
807 kwargs are additional arguments to ``np.isclose``
808 """
809 arr = np.array(arr, dtype=float)
810 diffs = np.diff(arr)
811 return bool(np.isclose(diffs.min(), diffs.max(), **kwargs))
812
813
814def hashable(v: Any) -> TypeGuard[Hashable]:

Callers

nothing calls this directly

Calls 3

diffMethod · 0.45
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…