MCPcopy
hub / github.com/pydata/xarray / test_upsample_tolerance

Method test_upsample_tolerance

xarray/tests/test_groupby.py:2173–2192  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2171 assert_identical(expected, actual)
2172
2173 def test_upsample_tolerance(self) -> None:
2174 # Test tolerance keyword for upsample methods bfill, pad, nearest
2175 times = pd.date_range("2000-01-01", freq="1D", periods=2)
2176 times_upsampled = pd.date_range("2000-01-01", freq="6h", periods=5)
2177 array = DataArray(np.arange(2), [("time", times)])
2178
2179 # Forward fill
2180 actual = array.resample(time="6h").ffill(tolerance="12h")
2181 expected = DataArray([0.0, 0.0, 0.0, np.nan, 1.0], [("time", times_upsampled)])
2182 assert_identical(expected, actual)
2183
2184 # Backward fill
2185 actual = array.resample(time="6h").bfill(tolerance="12h")
2186 expected = DataArray([0.0, np.nan, 1.0, 1.0, 1.0], [("time", times_upsampled)])
2187 assert_identical(expected, actual)
2188
2189 # Nearest
2190 actual = array.resample(time="6h").nearest(tolerance="6h")
2191 expected = DataArray([0, 0, np.nan, 1, 1], [("time", times_upsampled)])
2192 assert_identical(expected, actual)
2193
2194 @requires_scipy
2195 def test_upsample_interpolate(self) -> None:

Callers

nothing calls this directly

Calls 7

resampleMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90
arangeMethod · 0.80
nearestMethod · 0.80
ffillMethod · 0.45
bfillMethod · 0.45

Tested by

no test coverage detected