Skip to content

Commit

Permalink
update parametric tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Mar 27, 2024
1 parent da38eb5 commit ca7a3ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
22 changes: 16 additions & 6 deletions py-polars/tests/parametric/test_lazyframe.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ----------------------------------------------------
# Validate LazyFrame behaviour with parametric tests
# ----------------------------------------------------
from hypothesis import given
from hypothesis import example, given
from hypothesis.strategies import integers

import polars as pl
Expand All @@ -16,25 +16,35 @@
column(
"start",
dtype=pl.Int8,
null_probability=0.15,
strategy=integers(min_value=-4, max_value=6),
null_probability=0.3,
strategy=integers(min_value=-3, max_value=4),
),
column(
"stop",
dtype=pl.Int8,
null_probability=0.15,
strategy=integers(min_value=-2, max_value=8),
null_probability=0.3,
strategy=integers(min_value=-2, max_value=6),
),
column(
"step",
dtype=pl.Int8,
null_probability=0.15,
null_probability=0.3,
strategy=integers(min_value=-3, max_value=3).filter(lambda x: x != 0),
),
column("misc", dtype=pl.Int32),
],
)
)
@example(
ldf=pl.LazyFrame(
{
"start": [-1, None, 1, None, 1, -1],
"stop": [None, 0, -1, -1, 2, 1],
"step": [-1, -1, 1, None, -1, 1],
"misc": [1, 2, 3, 4, 5, 6],
}
)
)
def test_lazyframe_slice(ldf: pl.LazyFrame) -> None:
py_data = ldf.collect().rows()

Expand Down
3 changes: 1 addition & 2 deletions py-polars/tests/unit/operations/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def test_slice_pushdown_literal_projection_14349() -> None:

@pytest.mark.parametrize(
"input_slice",
# All these slices are not supported by LazyFrame, but they should raise properly.
[
(-1, None, -1),
(None, 0, -1),
Expand All @@ -237,7 +236,7 @@ def test_slice_pushdown_literal_projection_14349() -> None:
],
)
def test_slice_lazy_frame_raises_proper(input_slice: tuple[int | None]) -> None:
ldf = pl.LazyFrame({"a": [1, 2]})
ldf = pl.LazyFrame({"a": [1, 2, 3]})
s = slice(*input_slice)
with pytest.raises(ValueError, match="not supported"):
ldf[s].collect()

0 comments on commit ca7a3ad

Please sign in to comment.