Skip to content

Commit

Permalink
test(python): Avoid use of np.trapz in tests to prepare for NumPy 2…
Browse files Browse the repository at this point in the history
….0 (#17387)
  • Loading branch information
stinodego authored Jul 3, 2024
1 parent c6d0382 commit e2feeae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion py-polars/tests/unit/operations/map/test_map_batches.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_error_on_reducing_map() -> None:
r"the input length \(6\); consider using `apply` instead"
),
):
df.group_by("id").agg(pl.map_batches(["t", "y"], np.trapz))
df.group_by("id").agg(pl.map_batches(["t", "y"], np.mean))

df = pl.DataFrame({"x": [1, 2, 3, 4], "group": [1, 2, 1, 2]})

Expand Down
6 changes: 2 additions & 4 deletions py-polars/tests/unit/operations/map/test_map_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,8 @@ def test_map_groups_numpy_output_3057() -> None:
)

result = df.group_by("id", maintain_order=True).agg(
pl.map_groups(["y", "t"], lambda lst: np.trapz(y=lst[0], x=lst[1])).alias(
"result"
)
pl.map_groups(["y", "t"], lambda lst: np.mean([lst[0], lst[1]])).alias("result")
)

expected = pl.DataFrame({"id": [0, 1], "result": [1.955, 13.0]})
expected = pl.DataFrame({"id": [0, 1], "result": [2.266666, 7.333333]})
assert_frame_equal(result, expected)
2 changes: 1 addition & 1 deletion py-polars/tests/unit/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_error_on_reducing_map() -> None:
r"the input length \(6\); consider using `apply` instead"
),
):
df.group_by("id").agg(pl.map_batches(["t", "y"], np.trapz))
df.group_by("id").agg(pl.map_batches(["t", "y"], np.mean))

df = pl.DataFrame({"x": [1, 2, 3, 4], "group": [1, 2, 1, 2]})
with pytest.raises(
Expand Down

0 comments on commit e2feeae

Please sign in to comment.