Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 18cb697

Browse filesBrowse files
authored
Merge pull request #23478 from tacaswell/auto-backport-of-pr-23476-on-v3.5.x
Backport PR #23476: FIX: reset to original DPI in getstate
2 parents 4d02bc9 + b5f00d5 commit 18cb697
Copy full SHA for 18cb697

File tree

2 files changed

+12
-0
lines changed
Filter options

2 files changed

+12
-0
lines changed

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,6 +2886,9 @@ def __getstate__(self):
28862886
# Set cached renderer to None -- it can't be pickled.
28872887
state["_cachedRenderer"] = None
28882888

2889+
# discard any changes to the dpi due to pixel ratio changes
2890+
state["_dpi"] = state.get('_original_dpi', state['_dpi'])
2891+
28892892
# add version information to the state
28902893
state['__mpl_version__'] = mpl.__version__
28912894

‎lib/matplotlib/tests/test_figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_figure.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import datetime
22
import io
33
from pathlib import Path
4+
import pickle
45
import platform
56
from threading import Timer
67
from types import SimpleNamespace
@@ -1360,3 +1361,11 @@ def test_kwargs_pass():
13601361

13611362
assert fig.get_label() == 'whole Figure'
13621363
assert sub_fig.get_label() == 'sub figure'
1364+
1365+
1366+
def test_unpickle_with_device_pixel_ratio():
1367+
fig = Figure(dpi=42)
1368+
fig.canvas._set_device_pixel_ratio(7)
1369+
assert fig.dpi == 42*7
1370+
fig2 = pickle.loads(pickle.dumps(fig))
1371+
assert fig2.dpi == 42

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.