MCPcopy
hub / github.com/pydata/xarray / _check_timedelta_range

Function _check_timedelta_range

xarray/coding/times.py:413–430  ·  view source on GitHub ↗
(value, data_unit, time_unit)

Source from the content-addressed store, hash-verified

411
412
413def _check_timedelta_range(value, data_unit, time_unit):
414 if value > np.iinfo("int64").max or value < np.iinfo("int64").min:
415 OutOfBoundsTimedelta(f"Value {value} can't be represented as Timedelta.")
416 # on windows multiplying nan leads to RuntimeWarning
417 with warnings.catch_warnings():
418 warnings.filterwarnings(
419 "ignore", "invalid value encountered in multiply", RuntimeWarning
420 )
421 delta = value * np.timedelta64(1, data_unit)
422 if not np.isnan(delta):
423 # this will raise on dtype overflow for integer dtypes
424 if value.dtype.kind == "u" and not np.int64(delta) == value:
425 raise OutOfBoundsTimedelta(
426 "DType overflow in Datetime/Timedelta calculation."
427 )
428 # this will raise on overflow if delta cannot be represented with the
429 # resolutions supported by pandas.
430 pd.to_timedelta(delta)
431
432
433def _align_reference_date_and_unit(

Callers 1

decode_cf_timedeltaFunction · 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…