Skip to content

Commit

Permalink
fix: fix hashing specialization (#14754)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Feb 29, 2024
1 parent a2f5cf2 commit 8d0cdc2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/polars-core/src/frame/group_by/hashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ where
RawEntryMut::Vacant(entry) => {
let tuples = unitvec![idx];
entry.insert_with_hasher(hash, k, (idx, tuples), |k| {
hasher.hash_one(k)
hasher.hash_one(*k)
});
},
RawEntryMut::Occupied(mut entry) => {
Expand Down Expand Up @@ -288,7 +288,7 @@ where
RawEntryMut::Vacant(entry) => {
let tuples = unitvec![idx];
entry.insert_with_hasher(hash, k, (idx, tuples), |k| {
hasher.hash_one(k)
hasher.hash_one(*k)
});
},
RawEntryMut::Occupied(mut entry) => {
Expand Down
16 changes: 16 additions & 0 deletions py-polars/tests/unit/operations/test_aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,19 @@ def test_agg_empty_sum_after_filter_14734() -> None:
expect = pl.Series("b", [0, 0]).to_frame()
assert_frame_equal(expect, last.select("b"))
assert_frame_equal(expect, curr.select("b"))


@pytest.mark.slow()
def test_grouping_hash_14749() -> None:
n_groups = 251
rows_per_group = 4
assert (
pl.DataFrame(
{
"grp": np.repeat(np.arange(n_groups), rows_per_group),
"x": np.tile(np.arange(rows_per_group), n_groups),
}
)
.select(pl.col("x").max().over("grp"))["x"]
.value_counts()
).to_dict(as_series=False) == {"x": [3], "count": [1004]}

0 comments on commit 8d0cdc2

Please sign in to comment.