(
start, end, periods, freq, inclusive, normalize, calendar, expected_date_args
)
| 1238 | ids=_id_func, |
| 1239 | ) |
| 1240 | def test_cftime_range( |
| 1241 | start, end, periods, freq, inclusive, normalize, calendar, expected_date_args |
| 1242 | ): |
| 1243 | date_type = get_date_type(calendar) |
| 1244 | expected_dates = list(starmap(date_type, expected_date_args)) |
| 1245 | |
| 1246 | if isinstance(start, tuple): |
| 1247 | start = date_type(*start) |
| 1248 | if isinstance(end, tuple): |
| 1249 | end = date_type(*end) |
| 1250 | |
| 1251 | with pytest.warns(FutureWarning): |
| 1252 | result = cftime_range( |
| 1253 | start=start, |
| 1254 | end=end, |
| 1255 | periods=periods, |
| 1256 | freq=freq, |
| 1257 | inclusive=inclusive, |
| 1258 | normalize=normalize, |
| 1259 | calendar=calendar, |
| 1260 | ) |
| 1261 | resulting_dates = result.values |
| 1262 | |
| 1263 | assert isinstance(result, CFTimeIndex) |
| 1264 | |
| 1265 | if freq is not None: |
| 1266 | np.testing.assert_equal(resulting_dates, expected_dates) |
| 1267 | else: |
| 1268 | # If we create a linear range of dates using cftime.num2date |
| 1269 | # we will not get exact round number dates. This is because |
| 1270 | # datetime arithmetic in cftime is accurate approximately to |
| 1271 | # 1 millisecond (see https://unidata.github.io/cftime/api.html). |
| 1272 | deltas = resulting_dates - expected_dates |
| 1273 | deltas = np.array([delta.total_seconds() for delta in deltas]) |
| 1274 | assert np.max(np.abs(deltas)) < 0.001 |
| 1275 | |
| 1276 | |
| 1277 | def test_date_range_name(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…