File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -2886,6 +2886,9 @@ def __getstate__(self):
2886
2886
# Set cached renderer to None -- it can't be pickled.
2887
2887
state ["_cachedRenderer" ] = None
2888
2888
2889
+ # discard any changes to the dpi due to pixel ratio changes
2890
+ state ["_dpi" ] = state .get ('_original_dpi' , state ['_dpi' ])
2891
+
2889
2892
# add version information to the state
2890
2893
state ['__mpl_version__' ] = mpl .__version__
2891
2894
Original file line number Diff line number Diff line change 1
1
from datetime import datetime
2
2
import io
3
3
from pathlib import Path
4
+ import pickle
4
5
import platform
5
6
from threading import Timer
6
7
from types import SimpleNamespace
@@ -1360,3 +1361,11 @@ def test_kwargs_pass():
1360
1361
1361
1362
assert fig .get_label () == 'whole Figure'
1362
1363
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
You can’t perform that action at this time.
0 commit comments