(times)
| 106 | |
| 107 | |
| 108 | def _is_numpy_compatible_time_range(times): |
| 109 | if is_np_datetime_like(times.dtype): |
| 110 | return True |
| 111 | # times array contains cftime objects |
| 112 | times = np.asarray(times) |
| 113 | tmin = times.min() |
| 114 | tmax = times.max() |
| 115 | try: |
| 116 | # before relaxing the nanosecond constrained |
| 117 | # this raised OutOfBoundsDatetime for |
| 118 | # times < 1678 and times > 2262 |
| 119 | # this isn't the case anymore for other resolutions like "s" |
| 120 | # now, we raise for dates before 1582-10-15 |
| 121 | _check_date_is_after_shift(tmin, "standard") |
| 122 | _check_date_is_after_shift(tmax, "standard") |
| 123 | convert_time_or_go_back(tmin, pd.Timestamp) |
| 124 | convert_time_or_go_back(tmax, pd.Timestamp) |
| 125 | except pd.errors.OutOfBoundsDatetime: |
| 126 | return False |
| 127 | except ValueError as err: |
| 128 | if err.args[0] == "year 0 is out of range": |
| 129 | return False |
| 130 | raise |
| 131 | else: |
| 132 | return True |
| 133 | |
| 134 | |
| 135 | def _netcdf_to_numpy_timeunit(units: str) -> NPDatetimeUnitOptions: |
no test coverage detected
searching dependent graphs…