File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -788,6 +788,19 @@ class Grouper:
788788 def __init__ (self , init = ()):
789789 self ._mapping = {weakref .ref (x ): [weakref .ref (x )] for x in init }
790790
791+ def __getstate__ (self ):
792+ return {
793+ ** vars (self ),
794+ # Convert weak refs to strong ones.
795+ "_mapping" : {k (): [v () for v in vs ] for k , vs in self ._mapping .items ()},
796+ }
797+
798+ def __setstate__ (self , state ):
799+ vars (self ).update (state )
800+ # Convert strong refs to weak ones.
801+ self ._mapping = {weakref .ref (k ): [* map (weakref .ref , vs )]
802+ for k , vs in self ._mapping .items ()}
803+
791804 def __contains__ (self , item ):
792805 return weakref .ref (item ) in self ._mapping
793806
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ def _generate_complete_test_figure(fig_ref):
5858 # Ensure lists also pickle correctly.
5959 plt .subplot (3 , 3 , 1 )
6060 plt .plot (list (range (10 )))
61+ plt .ylabel ("hello" )
6162
6263 plt .subplot (3 , 3 , 2 )
6364 plt .contourf (data , hatches = ['//' , 'ooo' ])
@@ -68,6 +69,7 @@ def _generate_complete_test_figure(fig_ref):
6869
6970 plt .subplot (3 , 3 , 4 )
7071 plt .imshow (data )
72+ plt .ylabel ("hello\n world!" )
7173
7274 plt .subplot (3 , 3 , 5 )
7375 plt .pcolor (data )
@@ -89,6 +91,8 @@ def _generate_complete_test_figure(fig_ref):
8991 plt .subplot (3 , 3 , 9 )
9092 plt .errorbar (x , x * - 0.5 , xerr = 0.2 , yerr = 0.4 )
9193
94+ fig_ref .align_ylabels () # Test handling of _align_label_groups Groupers.
95+
9296
9397@mpl .style .context ("default" )
9498@check_figures_equal (extensions = ["png" ])
You can’t perform that action at this time.
0 commit comments