File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -311,7 +311,13 @@ def _is_bounds_strictly_monotonic(arr: np.ndarray) -> bool:
311
311
>>> _is_bounds_strictly_monotonic(bounds)
312
312
True
313
313
"""
314
- diffs = np .diff (arr , axis = - 2 )
314
+ # NOTE: Python 3.10 uses numpy 1.26.4. If the input is a datetime64 array,
315
+ # numpy 1.26.4 may raise: numpy.core._exceptions._UFuncInputCastingError:
316
+ # Cannot cast ufunc 'greater' input 0 from dtype('<m8[ns]') to dtype('<m8')
317
+ # with casting rule 'same_kind' To avoid this, always cast to float64 before
318
+ # np.diff.
319
+ arr_numeric = arr .astype ("float64" )
320
+ diffs = np .diff (arr_numeric , axis = - 2 )
315
321
strictly_increasing = np .all (diffs > 0 , axis = - 2 )
316
322
strictly_decreasing = np .all (diffs < 0 , axis = - 2 )
317
323
You can’t perform that action at this time.
0 commit comments