()
| 213 | |
| 214 | @requires_cftime |
| 215 | def test_convert_calendar_errors(): |
| 216 | src_nl = DataArray( |
| 217 | date_range("0000-01-01", "0000-12-31", freq="D", calendar="noleap"), |
| 218 | dims=("time",), |
| 219 | name="time", |
| 220 | ) |
| 221 | # no align_on for conversion to 360_day |
| 222 | with pytest.raises(ValueError, match="Argument `align_on` must be specified"): |
| 223 | convert_calendar(src_nl, "360_day") |
| 224 | |
| 225 | # Standard doesn't support year 0 |
| 226 | with pytest.raises( |
| 227 | ValueError, match="Source time coordinate contains dates with year 0" |
| 228 | ): |
| 229 | convert_calendar(src_nl, "standard") |
| 230 | |
| 231 | # no align_on for conversion from 360 day |
| 232 | src_360 = convert_calendar(src_nl, "360_day", align_on="year") |
| 233 | with pytest.raises(ValueError, match="Argument `align_on` must be specified"): |
| 234 | convert_calendar(src_360, "noleap") |
| 235 | |
| 236 | # Datetime objects |
| 237 | da = DataArray([0, 1, 2], dims=("x",), name="x") |
| 238 | with pytest.raises( |
| 239 | ValueError, match=r"Coordinate x must contain datetime objects." |
| 240 | ): |
| 241 | convert_calendar(da, "standard", dim="x") |
| 242 | |
| 243 | |
| 244 | def test_convert_calendar_dimension_name(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…