(calendar, unsafe)
| 1232 | @pytest.mark.parametrize("calendar", _ALL_CALENDARS) |
| 1233 | @pytest.mark.parametrize("unsafe", [False, True]) |
| 1234 | def test_to_datetimeindex(calendar, unsafe) -> None: |
| 1235 | index = xr.date_range("2000", periods=5, calendar=calendar, use_cftime=True) |
| 1236 | expected = pd.date_range("2000", periods=5, unit="ns") |
| 1237 | |
| 1238 | if calendar in _NON_STANDARD_CALENDAR_NAMES and not unsafe: |
| 1239 | with pytest.warns(RuntimeWarning, match="non-standard"): |
| 1240 | result = index.to_datetimeindex(time_unit="ns") |
| 1241 | else: |
| 1242 | result = index.to_datetimeindex(unsafe=unsafe, time_unit="ns") |
| 1243 | |
| 1244 | assert result.equals(expected) |
| 1245 | np.testing.assert_array_equal(result, expected) |
| 1246 | assert isinstance(result, pd.DatetimeIndex) |
| 1247 | |
| 1248 | |
| 1249 | @requires_cftime |
nothing calls this directly
no test coverage detected
searching dependent graphs…