File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -3023,6 +3023,9 @@ def __getstate__(self):
3023
3023
# Set cached renderer to None -- it can't be pickled.
3024
3024
state ["_cachedRenderer" ] = None
3025
3025
3026
+ # discard any changes to the dpi due to pixel ratio changes
3027
+ state ["_dpi" ] = state .get ('_original_dpi' , state ['_dpi' ])
3028
+
3026
3029
# add version information to the state
3027
3030
state ['__mpl_version__' ] = mpl .__version__
3028
3031
Original file line number Diff line number Diff line change 2
2
from datetime import datetime
3
3
import io
4
4
from pathlib import Path
5
+ import pickle
5
6
import platform
6
7
from threading import Timer
7
8
from types import SimpleNamespace
@@ -1380,3 +1381,11 @@ def test_deepcopy():
1380
1381
1381
1382
assert ax .get_xlim () == (1e-1 , 1e2 )
1382
1383
assert fig2 .axes [0 ].get_xlim () == (0 , 1 )
1384
+
1385
+
1386
+ def test_unpickle_with_device_pixel_ratio ():
1387
+ fig = Figure (dpi = 42 )
1388
+ fig .canvas ._set_device_pixel_ratio (7 )
1389
+ assert fig .dpi == 42 * 7
1390
+ fig2 = pickle .loads (pickle .dumps (fig ))
1391
+ assert fig2 .dpi == 42
You can’t perform that action at this time.
0 commit comments