@@ -269,7 +269,8 @@ def validate_backend(s):
269
269
270
270
271
271
validate_toolbar = ValidateInStrings (
272
- 'toolbar' , ['None' , 'toolbar2' , 'toolmanager' ], ignorecase = True )
272
+ 'toolbar' , ['None' , 'toolbar2' , 'toolmanager' ], ignorecase = True ,
273
+ _deprecated_since = "3.3" )
273
274
274
275
275
276
def _make_nseq_validator (cls , n = None , allow_none = False ):
@@ -478,7 +479,7 @@ def _update_savefig_format(value):
478
479
['auto' , 'letter' , 'legal' , 'ledger' ,
479
480
'a0' , 'a1' , 'a2' , 'a3' , 'a4' , 'a5' , 'a6' , 'a7' , 'a8' , 'a9' , 'a10' ,
480
481
'b0' , 'b1' , 'b2' , 'b3' , 'b4' , 'b5' , 'b6' , 'b7' , 'b8' , 'b9' , 'b10' ,
481
- ], ignorecase = True )
482
+ ], ignorecase = True , _deprecated_since = "3.3" )
482
483
483
484
484
485
def validate_ps_distiller (s ):
@@ -639,7 +640,7 @@ def validate_markevery(s):
639
640
'center right' ,
640
641
'lower center' ,
641
642
'upper center' ,
642
- 'center' ], ignorecase = True )
643
+ 'center' ], ignorecase = True , _deprecated_since = "3.3" )
643
644
644
645
validate_svg_fonttype = ValidateInStrings (
645
646
'svg.fonttype' , ['none' , 'path' ], _deprecated_since = "3.3" )
@@ -985,17 +986,29 @@ def validate_webagg_address(s):
985
986
'axes.titlelocation' , ['left' , 'center' , 'right' ], _deprecated_since = "3.3" )
986
987
987
988
989
+ class _ignorecase (list ):
990
+ """A marker class indicating that a list-of-str is case-insensitive."""
991
+
992
+
993
+ def _convert_validator_spec (key , conv ):
994
+ if isinstance (conv , list ):
995
+ ignorecase = isinstance (conv , _ignorecase )
996
+ return ValidateInStrings (key , conv , ignorecase = ignorecase )
997
+ else :
998
+ return conv
999
+
1000
+
988
1001
# A map of key -> [value, converter].
989
- # Converters given as lists are converted to ValidateInStrings immediately
990
- # below.
1002
+ # Converters given as lists or _ignorecase are converted to ValidateInStrings
1003
+ # immediately below.
991
1004
defaultParams = {
992
1005
'backend' : [_auto_backend_sentinel , validate_backend ],
993
1006
'backend_fallback' : [True , validate_bool ],
994
1007
'webagg.port' : [8988 , validate_int ],
995
1008
'webagg.address' : ['127.0.0.1' , validate_webagg_address ],
996
1009
'webagg.open_in_browser' : [True , validate_bool ],
997
1010
'webagg.port_retries' : [50 , validate_int ],
998
- 'toolbar' : ['toolbar2' , validate_toolbar ],
1011
+ 'toolbar' : ['toolbar2' , _ignorecase ([ 'none' , 'toolbar2' , 'toolmanager' ]) ],
999
1012
'datapath' : [None , validate_any ], # see _get_data_path_cached
1000
1013
'interactive' : [False , validate_bool ],
1001
1014
'timezone' : ['UTC' , validate_string ],
@@ -1232,7 +1245,13 @@ def validate_webagg_address(s):
1232
1245
1233
1246
#legend properties
1234
1247
'legend.fancybox' : [True , validate_bool ],
1235
- 'legend.loc' : ['best' , validate_legend_loc ],
1248
+ 'legend.loc' : ['best' ,
1249
+ _ignorecase (['best' ,
1250
+ 'upper right' , 'upper left' ,
1251
+ 'lower left' , 'lower right' , 'right' ,
1252
+ 'center left' , 'center right' ,
1253
+ 'lower center' , 'upper center' ,
1254
+ 'center' ])],
1236
1255
# the number of points in the legend line
1237
1256
'legend.numpoints' : [1 , validate_int ],
1238
1257
# the number of points in the legend line for scatter
@@ -1370,7 +1389,9 @@ def validate_webagg_address(s):
1370
1389
'tk.window_focus' : [False , validate_bool ],
1371
1390
1372
1391
# Set the papersize/type
1373
- 'ps.papersize' : ['letter' , validate_ps_papersize ],
1392
+ 'ps.papersize' : ['letter' ,
1393
+ _ignorecase (['auto' , 'letter' , 'legal' , 'ledger' ,
1394
+ * [f'{ ab } { i } ' for ab in 'ab' for i in range (11 )]])],
1374
1395
'ps.useafm' : [False , validate_bool ],
1375
1396
# use ghostscript or xpdf to distill ps output
1376
1397
'ps.usedistiller' : [False , validate_ps_distiller ],
@@ -1460,7 +1481,5 @@ def validate_webagg_address(s):
1460
1481
# altogether. For that use `matplotlib.style.use('classic')`.
1461
1482
'_internal.classic_mode' : [False , validate_bool ]
1462
1483
}
1463
- defaultParams = {
1464
- k : [default ,
1465
- ValidateInStrings (k , conv ) if isinstance (conv , list ) else conv ]
1466
- for k , (default , conv ) in defaultParams .items ()}
1484
+ defaultParams = {k : [default , _convert_validator_spec (k , conv )]
1485
+ for k , (default , conv ) in defaultParams .items ()}
0 commit comments