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: Add unique fast path for empty categoricals #20536

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

mcrumiller
Copy link
Contributor

Closes #20528.

I don't think this will interfere with @coastalwhite's upcoming fixes.

Evidence of fix:

>>> import polars as pl
>>> pl.enable_string_cache()
>>> pl.Series(["aaa", "bbb", "ccc"])  # pre-fill cache
>>> s = pl.Series(["a", "b", "c"], dtype=pl.Categorical)
>>> s_empty = s.slice(0, 0)          # create empty array
>>> s_empty.unique()
shape: (0,)
Series: '' [cat]
[
]
>>> s_empty.cat.get_categories()
shape: (3,)
Series: '' [str]
[
        "a"
        "b"
        "c"
]

@mcrumiller mcrumiller changed the title Fix: Add unique fast path for empty categoricals fix: Add unique fast path for empty categoricals Jan 2, 2025
@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars and removed title needs formatting labels Jan 2, 2025
Copy link

codecov bot commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.04%. Comparing base (1ebd039) to head (b2c4196).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20536      +/-   ##
==========================================
- Coverage   79.04%   79.04%   -0.01%     
==========================================
  Files        1563     1564       +1     
  Lines      220798   220621     -177     
  Branches     2502     2502              
==========================================
- Hits       174522   174380     -142     
+ Misses      45702    45667      -35     
  Partials      574      574              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mcrumiller mcrumiller marked this pull request as ready for review January 3, 2025 00:23
@ritchie46 ritchie46 merged commit 5c9bb71 into pola-rs:main Jan 3, 2025
26 checks passed
@mcrumiller mcrumiller deleted the unique-empty branch January 4, 2025 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unique() panics on empty global categorical series
2 participants