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

Function _is_monotonic

xarray/plot/utils.py:835–854  ·  view source on GitHub ↗

>>> _is_monotonic(np.array([0, 1, 2])) np.True_ >>> _is_monotonic(np.array([2, 1, 0])) np.True_ >>> _is_monotonic(np.array([0, 2, 1])) np.False_

(coord, axis=0)

Source from the content-addressed store, hash-verified

833
834
835def _is_monotonic(coord, axis=0):
836 """
837 >>> _is_monotonic(np.array([0, 1, 2]))
838 np.True_
839 >>> _is_monotonic(np.array([2, 1, 0]))
840 np.True_
841 >>> _is_monotonic(np.array([0, 2, 1]))
842 np.False_
843 """
844 if coord.shape[axis] < 3:
845 return True
846 else:
847 n = coord.shape[axis]
848 delta_pos = coord.take(np.arange(1, n), axis=axis) >= coord.take(
849 np.arange(0, n - 1), axis=axis
850 )
851 delta_neg = coord.take(np.arange(1, n), axis=axis) <= coord.take(
852 np.arange(0, n - 1), axis=axis
853 )
854 return np.all(delta_pos) or np.all(delta_neg)
855
856
857def _infer_interval_breaks(coord, axis=0, scale=None, check_monotonic=False):

Callers 1

_infer_interval_breaksFunction · 0.85

Calls 2

arangeMethod · 0.80
allMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…