code: def test_rolling() -> None:
      a = pl.Series("a", [1, 2, 3, 2, 1])
      assert_series_equal(
          a.rolling_min(2), pl.Series("a", [None, 1, 2, 2, 1])
      )
      assert_series_equal(
          a.rolling_max(2), pl.Series("a", [None, 2, 3, 3, 2])
      )
      assert_series_equal(
          a.rolling_sum(2), pl.Series("a", [None, 3, 5, 5, 3])
      )
      assert_series_equal(
          a.rolling_mean(2), pl.Series("a", [None, 1.5, 2.5, 2.5, 1.5])
      )
  
      assert a.rolling_std(2).to_list()[1] == pytest.approx(
          0.7071067811865476
      )
      assert a.rolling_var(2).to_list()[1] == pytest.approx(0.5)
      assert a.rolling_std(2, ddof=0).to_list()[1] == pytest.approx(0.5)
      assert a.rolling_var(2, ddof=0).to_list()[1] == pytest.approx(
          0.25
      )
  
      assert_series_equal(
          a.rolling_median(4),
          pl.Series("a", [None, None, None, 2, 2], dtype=pl.Float64),
      )
      assert_series_equal(
          a.rolling_quantile(0, "nearest", 3),
          pl.Series("a", [None, None, 1, 2, 1], dtype=pl.Float64),
      )
      assert_series_equal(
          a.rolling_quantile(0, "lower", 3),
          pl.Series("a", [None, None, 1, 2, 1], dtype=pl.Float64),
      )
      assert_series_equal(
          a.rolling_quantile(0, "higher", 3),
          pl.Series("a", [None, None, 1, 2, 1], dtype=pl.Float64),
      )
      assert a.rolling_skew(4).null_count() == 3
  
      # 3099
      # test if we maintain proper dtype
      for dt in [pl.Float32, pl.Float64]:
          result = pl.Series([1, 2, 3], dtype=dt).rolling_min(
              2, weights=[0.1, 0.2]
          )
          expected = pl.Series([None, 0.1, 0.2], dtype=dt)
          assert_series_equal(result, expected)
  
      df = pl.DataFrame({"val": [1.0, 2.0, 3.0, np.nan, 5.0, 6.0, 7.0]})
  
      for e in [
          pl.col("val").rolling_min(window_size=3),
          pl.col("val").rolling_max(window_size=3),
      ]:
          out = df.with_columns(e).to_series()
          assert out.null_count() == 2
          assert np.isnan(out.to_numpy()).sum() == 5
  
      expected_values = [None, None, 2.0, 3.0, 5.0, 6.0, 6.0]
      assert (
          df.with_columns(pl.col("val").rolling_median(window_size=3))
          .to_series()
          .to_list()
          == expected_values
      )
      assert (
          df.with_columns(
              pl.col("val").rolling_quantile(0.5, window_size=3)
          )
          .to_series()
          .to_list()
          == expected_values
      )
  
      nan = float("nan")
      a = pl.Series("a", [11.0, 2.0, 9.0, nan, 8.0])
      assert_series_equal(
          a.rolling_sum(3),
          pl.Series("a", [None, None, 22.0, nan, nan]),
      )
  
imports: from __future__ import annotations
  from datetime import date, datetime, timedelta
  from typing import TYPE_CHECKING
  import numpy
  import pytest
  from numpy import nan
  import polars
  from polars.exceptions import ComputeError
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 22 for calling a global function with example usage: test_rolling() without return types