(value, data_unit, time_unit)
| 411 | |
| 412 | |
| 413 | def _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 | |
| 433 | def _align_reference_date_and_unit( |
no outgoing calls
no test coverage detected
searching dependent graphs…