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):
30233023 # Set cached renderer to None -- it can't be pickled.
30243024 state ["_cachedRenderer" ] = None
30253025
3026+ # discard any changes to the dpi due to pixel ratio changes
3027+ state ["_dpi" ] = state .get ('_original_dpi' , state ['_dpi' ])
3028+
30263029 # add version information to the state
30273030 state ['__mpl_version__' ] = mpl .__version__
30283031
Original file line number Diff line number Diff line change 22from datetime import datetime
33import io
44from pathlib import Path
5+ import pickle
56import platform
67from threading import Timer
78from types import SimpleNamespace
@@ -1380,3 +1381,11 @@ def test_deepcopy():
13801381
13811382 assert ax .get_xlim () == (1e-1 , 1e2 )
13821383 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