(self)
| 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. |
nothing calls this directly
no test coverage detected