Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Flaky test_extension test #20433

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions py-polars/tests/unit/dataframe/test_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -1813,29 +1813,29 @@ def __repr__(self) -> str:
foos = [Foo(1), Foo(2), Foo(3)]
# foos and sys.getrefcount have a reference.
base_count = 2
assert sys.getrefcount(foos[0]) == base_count
assert sys.getrefcount(foos[0]) >= base_count

df = pl.DataFrame({"groups": [1, 1, 2], "a": foos})
assert sys.getrefcount(foos[0]) == base_count + 1
assert sys.getrefcount(foos[0]) >= base_count + 1
del df
assert sys.getrefcount(foos[0]) == base_count
assert sys.getrefcount(foos[0]) >= base_count

df = pl.DataFrame({"groups": [1, 1, 2], "a": foos})
assert sys.getrefcount(foos[0]) == base_count + 1
assert sys.getrefcount(foos[0]) >= base_count + 1

out = df.group_by("groups", maintain_order=True).agg(pl.col("a").alias("a"))
assert sys.getrefcount(foos[0]) == base_count + 2
assert sys.getrefcount(foos[0]) >= base_count + 2
s = out["a"].list.explode()
assert sys.getrefcount(foos[0]) == base_count + 3
assert sys.getrefcount(foos[0]) >= base_count + 3
del s
assert sys.getrefcount(foos[0]) == base_count + 2
assert sys.getrefcount(foos[0]) >= base_count + 2

assert out["a"].list.explode().to_list() == foos
assert sys.getrefcount(foos[0]) == base_count + 2
assert sys.getrefcount(foos[0]) >= base_count + 2
del out
assert sys.getrefcount(foos[0]) == base_count + 1
assert sys.getrefcount(foos[0]) >= base_count + 1
del df
assert sys.getrefcount(foos[0]) == base_count
assert sys.getrefcount(foos[0]) >= base_count


@pytest.mark.parametrize("name", [None, "n", ""])
Expand Down
Loading