We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d7ad089 commit 6948d47Copy full SHA for 6948d47
cf_xarray/helpers.py
@@ -301,7 +301,12 @@ def _is_bounds_strictly_monotonic(arr: np.ndarray) -> bool:
301
# np.diff.
302
arr_numeric = arr.astype("float64").flatten()
303
diffs = np.diff(arr_numeric)
304
- return np.all(diffs > 0) or np.all(diffs < 0)
+ nonzero_diffs = diffs[diffs != 0]
305
+
306
+ if nonzero_diffs.size == 0:
307
+ return True # All values are equal, treat as monotonic
308
309
+ return np.all(nonzero_diffs > 0) or np.all(nonzero_diffs < 0)
310
311
312
def is_bounds_ascending(bounds: np.ndarray) -> bool:
0 commit comments