Skip to content

BUG: Deepcopy the plot saved as last_plot#1069

Open
has2k1 wants to merge 1 commit into
mainfrom
fix-last-plot
Open

BUG: Deepcopy the plot saved as last_plot#1069
has2k1 wants to merge 1 commit into
mainfrom
fix-last-plot

Conversation

@has2k1
Copy link
Copy Markdown
Owner

@has2k1 has2k1 commented Jun 8, 2026

plot_context stored the in-progress plot via a shallow copy, so the object returned by last_plot() shared mutable nested state (e.g. the theme) with the plot being built. Building mutated that shared state, leaving last_plot() referencing a half-built plot.

As a result, code like

last_plot() + labs(subtitle="ab")

failed to left-align the title, because the title's alignment had already been altered in the shared state during the previous build.

Use deepcopy so last_plot() is an independent, pristine snapshot.

plot_context stored the in-progress plot via a shallow copy, so the
object returned by last_plot() shared mutable nested state (e.g. the
theme) with the plot being built. Building mutated that shared state,
leaving last_plot() referencing a half-built plot.

As a result, code like

    last_plot() + labs(subtitle="ab")

failed to left-align the title, because the title's alignment had
already been altered in the shared state during the previous build.

Use deepcopy so last_plot() is an independent, pristine snapshot.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.10%. Comparing base (88ff84e) to head (67fc88b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1069   +/-   ##
=======================================
  Coverage   87.10%   87.10%           
=======================================
  Files         208      208           
  Lines       14321    14321           
  Branches     1788     1788           
=======================================
  Hits        12474    12474           
  Misses       1283     1283           
  Partials      564      564           

☔ 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.

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