code: def test_sample_series() -> None:
      s = pl.Series("a", [1, 2, 3, 4, 5])
  
      assert len(s.sample(n=2, seed=0)) == 2
      assert len(s.sample(fraction=0.4, seed=0)) == 2
  
      assert len(s.sample(n=2, with_replacement=True, seed=0)) == 2
  
      # on a series of length 5, you cannot sample more than 5 items
      with pytest.raises(pl.ShapeError):
          s.sample(n=10, with_replacement=False, seed=0)
      # unless you use with_replacement=True
      assert len(s.sample(n=10, with_replacement=True, seed=0)) == 10
  
file_path: polars/py-polars/tests/unit/operations/test_random.py
imports: from __future__ import annotations
  import pytest
  import polars
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 6 for calling a global function with example usage: test_sample_series() without return types