(self, center, window, min_periods)
| 686 | @pytest.mark.parametrize("min_periods", (None, 1, 2, 3)) |
| 687 | @pytest.mark.parametrize("window", (1, 2, 3, 4)) |
| 688 | def test_rolling_pandas_compat(self, center, window, min_periods) -> None: |
| 689 | df = pd.DataFrame( |
| 690 | { |
| 691 | "x": np.random.randn(20), |
| 692 | "y": np.random.randn(20), |
| 693 | "time": np.linspace(0, 1, 20), |
| 694 | } |
| 695 | ) |
| 696 | ds = Dataset.from_dataframe(df) |
| 697 | |
| 698 | if min_periods is not None and window < min_periods: |
| 699 | min_periods = window |
| 700 | |
| 701 | df_rolling = df.rolling(window, center=center, min_periods=min_periods).mean() |
| 702 | ds_rolling = ds.rolling( |
| 703 | index=window, center=center, min_periods=min_periods |
| 704 | ).mean() |
| 705 | |
| 706 | np.testing.assert_allclose( |
| 707 | np.asarray(df_rolling["x"].values), ds_rolling["x"].values |
| 708 | ) |
| 709 | np.testing.assert_allclose(df_rolling.index, ds_rolling["index"]) |
| 710 | |
| 711 | @pytest.mark.parametrize("center", (True, False)) |
| 712 | @pytest.mark.parametrize("window", (1, 2, 3, 4)) |
nothing calls this directly
no test coverage detected