Skip to content

fix(scale_linetype): report default palette capacity clearly - #1139

Open
senanurcetin wants to merge 3 commits into
has2k1:mainfrom
senanurcetin:fix/linetype-capacity-error
Open

senanurcetin wants to merge 3 commits into
has2k1:mainfrom
senanurcetin:fix/linetype-capacity-error

Conversation

@senanurcetin

@senanurcetin senanurcetin commented Oct 18, 2026 •

Copy link
Copy Markdown

Summary

Related to #351.

The default discrete linetype scale has only four patterns. With more than four categories it produced missing values and eventually failed with the unhelpful ValueError: Unrecognized linestyle: nan. It now raises a PlotnineError that explains the four-category limit and points to scale_linetype_manual().

Changes

  • Raise a clear PlotnineError when the default linetype palette's capacity is exceeded (plotnine/scales/scale_linetype.py).
  • Behaviour for four or fewer categories is unchanged; no new default patterns are added.
  • Add three regression tests (palette limit, plotting, manual-scale workaround) and update the existing palette test in tests/test_scale_internals.py to expect the new error.

Testing

Windows / Python 3.13: 59 tests passed across test_scale_internals.py and test_scale_linetype.py; Ruff lint/format clean. The original error was reproduced before the fix. The full test suite was not run locally.

AI assistance

AI assistance (ChatGPT) was used during implementation, regression testing, and validation.

@senanurcetin

Copy link
Copy Markdown
Author

Hi Plotnine maintainers,

I've submitted a focused fix to provide a clearer error when the default discrete linetype scale exceeds its four-category limit.

The PR also includes regression tests covering the default palette limit, the error message, and the manual linetype workaround.

I noticed that the build workflow is marked as action_required. If maintainer approval is necessary, could you please enable the checks when appropriate?

AI assistance was used in preparing this contribution.

Thank you for considering the PR!

Raise an actionable PlotnineError when the built-in palette is asked
for more than four categories, and cover the boundary and manual
linetype workaround with regression tests.
@senanurcetin
senanurcetin force-pushed the fix/linetype-capacity-error branch from 0dee7fb to a6c3c54 Compare October 20, 2026 22:34
Preserve the existing three-file PR patch unchanged while absorbing upstream
compatibility and CI fixes. Both parents retained; no force-push.

Verified upstream main passed all seven CI jobs. Latest upstream commits did
not modify any of the three files changed by this PR. Full branch CI awaits
this merge commit; no tests claimed as locally run.
@senanurcetin

Copy link
Copy Markdown
Author

Closing this to keep my open pull requests to a number I can follow up on properly. The branch stays on my fork, so if this change is still wanted I'm happy to reopen it. Thanks for your time.

@has2k1 has2k1 reopened this Nov 11, 2026
@has2k1

has2k1 commented Nov 11, 2026

Copy link
Copy Markdown
Owner

This PR will get in sometime before the upcoming v0.16.0 release.

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.92%. Comparing base (2431ef4) to head (119d1ab).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1139   +/-   ##
=======================================
  Coverage   88.92%   88.92%           
=======================================
  Files         229      229           
  Lines       17320    17326    +6     
  Branches     2204     2205    +1     
=======================================
+ Hits        15402    15408    +6     
  Misses       1289     1289           
  Partials      629      629           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@senanurcetin

Copy link
Copy Markdown
Author

Thanks for reopening this. I'll keep the branch up to date and am happy to make any changes you'd like before v0.16.0.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants