[codex] Fix facet grid categorical missing IDs#1092
Merged
has2k1 merged 2 commits intoJul 3, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1092 +/- ##
==========================================
+ Coverage 87.29% 87.46% +0.16%
==========================================
Files 208 208
Lines 14602 14703 +101
Branches 1825 1834 +9
==========================================
+ Hits 12747 12860 +113
+ Misses 1282 1274 -8
+ Partials 573 569 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Both the drop and no-drop paths now share one recoding of the categorical codes, and the non-categorical path uses match(start=1) instead of a manual increment.
af6d551 to
8f228ad
Compare
Owner
|
@EltonChang1, thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
drop=Trueso missing categorical values receive a positive panel id after the used categories instead of0.facet_gridwith missing categorical facet values and for the underlyingninteractionhelper.Fixes #1086.
Why
When a categorical facet variable contained missing values,
_id_var(..., drop=True)converted pandas category code-1to0.facet_gridthen built layout rows with column0whilencolwas based on the positive category IDs, so strip setup tried to access more panel entries than there were axes and raisedIndexError.Validation
facet_grid("R ~ C")now draws successfully..venv/bin/python -m pytest tests/test_utils.py -k "ninteraction" -q.venv/bin/python -m pytest tests/test_facets.py -k "missing_categorical or unused_categories" -q.venv/bin/python -m pytest tests/test_utils.py tests/test_facets.py -q.venv/bin/python -m ruff check plotnine/_utils/__init__.py tests/test_utils.py tests/test_facets.py.venv/bin/python -m ruff format --check plotnine/_utils/__init__.py tests/test_utils.py tests/test_facets.pygit diff --checkLimitations
Full repository test suite was not run locally; this change was validated with the affected utility and facet test files plus targeted lint/format checks.
AI Disclosure
This draft PR was prepared with assistance from OpenAI Codex/ChatGPT. Codex helped reproduce the issue, inspect the facet layout code, implement the focused fix, add tests, and run validation. The final diff and PR text were reviewed in this local checkout before submission.