(use_dask: bool, date: str)
| 2439 | ) |
| 2440 | @pytest.mark.parametrize("date", ["1970-01-01", "0753-04-21"]) |
| 2441 | def test_polyval_cftime(use_dask: bool, date: str) -> None: |
| 2442 | import cftime |
| 2443 | |
| 2444 | x = xr.DataArray( |
| 2445 | xr.date_range(date, freq="1s", periods=3, use_cftime=True), |
| 2446 | dims="x", |
| 2447 | ) |
| 2448 | coeffs = xr.DataArray([0, 1], dims="degree", coords={"degree": [0, 1]}) |
| 2449 | |
| 2450 | if use_dask: |
| 2451 | if not has_dask: |
| 2452 | pytest.skip("requires dask") |
| 2453 | coeffs = coeffs.chunk({"degree": 2}) |
| 2454 | x = x.chunk({"x": 2}) |
| 2455 | |
| 2456 | with raise_if_dask_computes(max_computes=1): |
| 2457 | actual = xr.polyval(coord=x, coeffs=coeffs) |
| 2458 | |
| 2459 | t0 = xr.date_range(date, periods=1)[0] |
| 2460 | offset = (t0 - cftime.DatetimeGregorian(1970, 1, 1)).total_seconds() * 1e9 |
| 2461 | expected = ( |
| 2462 | xr.DataArray( |
| 2463 | [0, 1e9, 2e9], |
| 2464 | dims="x", |
| 2465 | coords={"x": xr.date_range(date, freq="1s", periods=3, use_cftime=True)}, |
| 2466 | ) |
| 2467 | + offset |
| 2468 | ) |
| 2469 | xr.testing.assert_allclose(actual, expected) |
| 2470 | |
| 2471 | |
| 2472 | def test_polyval_degree_dim_checks() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…