code: def test_sample_empty_df() -> None:
      df = pl.DataFrame({"foo": []})
  
      # // If with replacement, then expect empty df
      assert df.sample(n=3, with_replacement=True).shape == (0, 1)
      assert df.sample(fraction=0.4, with_replacement=True).shape == (
          0,
          1,
      )
  
      # // If without replacement, then expect shape mismatch on sample_n not sample_frac
      with pytest.raises(pl.ShapeError):
          df.sample(n=3, with_replacement=False)
      assert df.sample(fraction=0.4, with_replacement=False).shape == (
          0,
          1,
      )
  
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 5 for calling a global function with example usage: test_sample_empty_df() without return types