MCPcopy Index your code
hub / github.com/pydata/xarray / test_upsample

Method test_upsample

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

Source from the content-addressed store, hash-verified

2082 assert_identical(result, expected)
2083
2084 def test_upsample(self) -> None:
2085 times = pd.date_range("2000-01-01", freq="6h", periods=5)
2086 array = DataArray(np.arange(5), [("time", times)])
2087
2088 # Forward-fill
2089 actual = array.resample(time="3h").ffill()
2090 expected = DataArray(array.to_series().resample("3h").ffill())
2091 assert_identical(expected, actual)
2092
2093 # Backward-fill
2094 actual = array.resample(time="3h").bfill()
2095 expected = DataArray(array.to_series().resample("3h").bfill())
2096 assert_identical(expected, actual)
2097
2098 # As frequency
2099 actual = array.resample(time="3h").asfreq()
2100 expected = DataArray(array.to_series().resample("3h").asfreq())
2101 assert_identical(expected, actual)
2102
2103 # Pad
2104 actual = array.resample(time="3h").pad()
2105 expected = DataArray(array.to_series().resample("3h").ffill())
2106 assert_identical(expected, actual)
2107
2108 # Nearest
2109 rs = array.resample(time="3h")
2110 actual = rs.nearest()
2111 new_times = rs.groupers[0].full_index
2112 expected = DataArray(array.reindex(time=new_times, method="nearest"))
2113 assert_identical(expected, actual)
2114
2115 def test_upsample_nd(self) -> None:
2116 # Same as before, but now we try on multi-dimensional DataArrays.

Callers

nothing calls this directly

Calls 12

resampleMethod · 0.95
to_seriesMethod · 0.95
reindexMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90
arangeMethod · 0.80
nearestMethod · 0.80
ffillMethod · 0.45
resampleMethod · 0.45
bfillMethod · 0.45
asfreqMethod · 0.45
padMethod · 0.45

Tested by

no test coverage detected