Closed
Description
What happened?
ffill
, bfill
reindex
etc. have tolerance arguments that also supports strings. And we test for it here:
xarray/xarray/tests/test_groupby.py
Lines 2016 to 2025 in 2120808
But our typing assumes it's floats only:
xarray/xarray/core/resample.py
Lines 69 to 94 in 2120808
What did you expect to happen?
Since our pytests pass, mypy should pass as well.
Minimal Complete Verifiable Example
import numpy as np
import pandas as pd
import xarray as xr
# https://github.com/pydata/xarray/blob/2120808bbe45f3d4f0b6a01cd43bac4df4039092/xarray/tests/test_groupby.py#L2016
# Test tolerance keyword for upsample methods bfill, pad, nearest
times = pd.date_range("2000-01-01", freq="1D", periods=2)
times_upsampled = pd.date_range("2000-01-01", freq="6h", periods=5)
array = xr.DataArray(np.arange(2), [("time", times)])
# Forward fill
actual = array.resample(time="6h").ffill(tolerance="12h")
expected = xr.DataArray([0.0, 0.0, 0.0, np.nan, 1.0], [("time", times_upsampled)])
xr.testing.assert_identical(expected, actual)
Environment
master