Skip to content

Fix plot_spacer theme and arithmetic - #1057

Merged
has2k1 merged 3 commits into
mainfrom
fix-spacer-theme
May 4, 2026
Merged

Fix plot_spacer theme and arithmetic#1057
has2k1 merged 3 commits into
mainfrom
fix-spacer-theme

Conversation

@has2k1

@has2k1 has2k1 commented May 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

@codecov

codecov Bot commented May 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.87%. Comparing base (429a37a) to head (7d85258).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
plotnine/ggplot.py 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1057      +/-   ##
==========================================
+ Coverage   86.81%   86.87%   +0.06%     
==========================================
  Files         203      203              
  Lines       13759    13757       -2     
  Branches     1689     1688       -1     
==========================================
+ Hits        11945    11952       +7     
+ Misses       1265     1256       -9     
  Partials      549      549              

☔ View full report in Codecov by Sentry.
📢 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.

@has2k1
has2k1 force-pushed the fix-spacer-theme branch 2 times, most recently from 202f65d to 9b2b935 Compare May 4, 2026 12:53
@has2k1 has2k1 changed the title Fix spacer theme Fix plot_spacer theme and arithmetic May 4, 2026
has2k1 added 3 commits May 4, 2026 15:57
Promote return types from ggplot/Compose to Self where the body
preserves the runtime class — ggplot's __deepcopy__, __add__ overloads,
__or__/__truediv__/__sub__/__rrshift__, and Compose's __and__/__mul__.
The other Compose operators (__or__, __truediv__, __sub__, __add__)
keep Compose as their return type because they cross-construct
(e.g. Stack | x → Beside) and would be unsound as Self.

Also type the rhs of plot_spacer's __add__/__iadd__ explicitly so the
override is visible to pyright.
plot_annotation now controls the composition's figure size and dpi via
Compose.theme; the per-spacer values forwarded into __add__ are no
longer read by anything.
Compose.__and__/__mul__ apply themes to items via item += rhs, which
dispatches to ggplot.__iadd__ → theme.__radd__. For a complete theme
that takes the "replace" branch, overwriting the spacer's theme_void()
foundation so the spacer paints a panel.

Override __iadd__ on plot_spacer to merge only plot_background into the
existing theme_void(), and have __add__ delegate via deepcopy → __iadd__
so the merge logic lives in one place.

plot_spacer.__add__ used to silently swallow any non-PlotAddable rhs,
so spacer + plot was a no-op. Match ggplot.__add__'s contract: ggplot
or Compose on the right composes into a Wrap, just like plot + plot.
A theme still contributes only its plot_background fill into the
spacer's theme_void() foundation.

closes #1055
@has2k1
has2k1 force-pushed the fix-spacer-theme branch from 9b2b935 to 7d85258 Compare May 4, 2026 12:57
@has2k1
has2k1 merged commit 7d85258 into main May 4, 2026
13 checks passed
@has2k1
has2k1 deleted the fix-spacer-theme branch May 4, 2026 12:59
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.

1 participant