21
21
22
22
import numpy as np
23
23
24
- from matplotlib import _api , animation , cbook
24
+ from matplotlib import _api , cbook
25
25
from matplotlib .cbook import ls_mapper
26
26
from matplotlib .colors import Colormap , is_color_like
27
27
from matplotlib .fontconfig_pattern import parse_fontconfig_pattern
@@ -146,21 +146,6 @@ def validate_bool(b):
146
146
raise ValueError ('Could not convert "%s" to bool' % b )
147
147
148
148
149
- @_api .deprecated ("3.3" )
150
- def validate_bool_maybe_none (b ):
151
- """Convert b to ``bool`` or raise, passing through *None*."""
152
- if isinstance (b , str ):
153
- b = b .lower ()
154
- if b is None or b == 'none' :
155
- return None
156
- if b in ('t' , 'y' , 'yes' , 'on' , 'true' , '1' , 1 , True ):
157
- return True
158
- elif b in ('f' , 'n' , 'no' , 'off' , 'false' , '0' , 0 , False ):
159
- return False
160
- else :
161
- raise ValueError ('Could not convert "%s" to bool' % b )
162
-
163
-
164
149
def _validate_date_converter (s ):
165
150
if s is None :
166
151
return
@@ -181,42 +166,13 @@ def _validate_date_int_mult(s):
181
166
mdates ._rcParam_helper .set_int_mult (s )
182
167
183
168
184
- def _validate_tex_preamble (s ):
185
- if s is None or s == 'None' :
186
- _api .warn_deprecated (
187
- "3.3" , message = "Support for setting the 'text.latex.preamble' or "
188
- "'pgf.preamble' rcParam to None is deprecated since %(since)s and "
189
- "will be removed %(removal)s; set it to an empty string instead." )
190
- return ""
191
- try :
192
- if isinstance (s , str ):
193
- return s
194
- elif np .iterable (s ):
195
- _api .warn_deprecated (
196
- "3.3" , message = "Support for setting the 'text.latex.preamble' "
197
- "or 'pgf.preamble' rcParam to a list of strings is deprecated "
198
- "since %(since)s and will be removed %(removal)s; set it to a "
199
- "single string instead." )
200
- return '\n ' .join (s )
201
- else :
202
- raise TypeError
203
- except TypeError as e :
204
- raise ValueError ('Could not convert "%s" to string' % s ) from e
205
-
206
-
207
169
def validate_axisbelow (s ):
208
170
try :
209
171
return validate_bool (s )
210
172
except ValueError :
211
173
if isinstance (s , str ):
212
174
if s == 'line' :
213
175
return 'line'
214
- if s .lower ().startswith ('line' ):
215
- _api .warn_deprecated (
2
F438
16
- "3.3" , message = f"Support for setting axes.axisbelow to "
217
- f"{ s !r} to mean 'line' is deprecated since %(since)s and "
218
- f"will be removed %(removal)s; set it to 'line' instead." )
219
- return 'line'
220
176
raise ValueError ('%s cannot be interpreted as'
221
177
' True, False, or "line"' % s )
222
178
@@ -303,11 +259,6 @@ def validate_backend(s):
303
259
return backend
304
260
305
261
306
- validate_toolbar = ValidateInStrings (
307
- 'toolbar' , ['None' , 'toolbar2' , 'toolmanager' ], ignorecase = True ,
308
- _deprecated_since = "3.3" )
309
-
310
-
311
262
def _validate_toolbar (s ):
312
263
s = ValidateInStrings (
313
264
'toolbar' , ['None' , 'toolbar2' , 'toolmanager' ], ignorecase = True )(s )
@@ -318,42 +269,6 @@ def _validate_toolbar(s):
318
269
return s
319
270
320
271
321
- @_api .deprecated ("3.3" )
322
- def _make_nseq_validator (cls , n = None , allow_none = False ):
323
-
324
- def validator (s ):
325
- """Convert *n* objects using ``cls``, or raise."""
326
- if isinstance (s , str ):
327
- s = [x .strip () for x in s .split (',' )]
328
- if n is not None and len (s ) != n :
329
- raise ValueError (
330
- f'Expected exactly { n } comma-separated values, '
331
- f'but got { len (s )} comma-separated values: { s } ' )
332
- else :
333
- if n is not None and len (s ) != n :
334
- raise ValueError (
335
- f'Expected exactly { n } values, '
336
- f'but got { len (s )} values: { s } ' )
337
- try :
338
- return [cls (val ) if not allow_none or val is not None else val
339
- for val in s ]
340
- except ValueError as e :
341
- raise ValueError (
342
- f'Could not convert all entries to { cls .__name__ } s' ) from e
343
-
344
- return validator
345
-
346
-
347
- @_api .deprecated ("3.3" )
348
- def validate_nseq_float (n ):
349
- return _make_nseq_validator (float , n )
350
-
351
-
352
- @_api .deprecated ("3.3" )
353
- def validate_nseq_int (n ):
354
- return _make_nseq_validator (int , n )
355
-
356
-
357
272
def validate_color_or_inherit (s ):
358
273
"""Return a valid color arg."""
359
274
if cbook ._str_equal (s , 'inherit' ):
@@ -408,10 +323,6 @@ def _validate_cmap(s):
408
323
return s
409
324
410
325
411
- validate_orientation = ValidateInStrings (
412
- 'orientation' , ['landscape' , 'portrait' ], _deprecated_since = "3.3" )
413
-
414
-
415
326
def validate_aspect (s ):
416
327
if s in ('auto' , 'equal' ):
417
328
return s
@@ -478,19 +389,6 @@ def _validate_mathtext_fallback(s):
478
389
"fallback off." )
479
390
480
391
481
- validate_fontset = ValidateInStrings (
482
- 'fontset' ,
483
- ['dejavusans' , 'dejavuserif' , 'cm' , 'stix' , 'stixsans' , 'custom' ],
484
- _deprecated_since = "3.3" )
485
- validate_mathtext_default = ValidateInStrings (
486
- 'default' , "rm cal it tt sf bf default bb frak scr regular" .split (),
487
- _deprecated_since = "3.3" )
488
- _validate_alignment = ValidateInStrings (
489
- 'alignment' ,
490
- ['center' , 'top' , 'bottom' , 'baseline' , 'center_baseline' ],
491
- _deprecated_since = "3.3" )
492
-
493
-
494
392
def validate_whiskers (s ):
495
393
try :
496
394
return _listify_validator (validate_float , n = 2 )(s )
@@ -502,14 +400,6 @@ def validate_whiskers(s):
502
400
"(float, float)]" ) from e
503
401
504
402
505
- validate_ps_papersize = ValidateInStrings (
506
- 'ps_papersize' ,
507
- ['auto' , 'letter' , 'legal' , 'ledger' ,
508
- 'a0' , 'a1' , 'a2' , 'a3' , 'a4' , 'a5' , 'a6' , 'a7' , 'a8' , 'a9' , 'a10' ,
509
- 'b0' , 'b1' , 'b2' , 'b3' , 'b4' , 'b5' , 'b6' , 'b7' , 'b8' , 'b9' , 'b10' ,
510
- ], ignorecase = True , _deprecated_since = "3.3" )
511
-
512
-
513
403
def validate_ps_distiller (s ):
514
404
if isinstance (s , str ):
515
405
s = s .lower ()
@@ -547,25 +437,20 @@ def _is_iterable_not_string_like(x):
547
437
# nonsensically interpreted as sequences of numbers (codepoints).
548
438
return np .iterable (x ) and not isinstance (x , (str , bytes , bytearray ))
549
439
550
- # (offset, (on, off, on, off, ...))
551
- if (_is_iterable_not_string_like (ls )
552
- and len (ls ) == 2
553
- and isinstance (ls [0 ], (type (None ), Number ))
554
- and _is_iterable_not_string_like (ls [1 ])
555
- and len (ls [1 ]) % 2 == 0
556
- and all (isinstance (elem , Number ) for elem in ls [1 ])):
557
- if ls [0 ] is None :
558
- _api .warn_deprecated (
559
- "3.3" , message = "Passing the dash offset as None is deprecated "
560
- "since %(since)s and support for it will be removed "
561
- "%(removal)s; pass it as zero instead." )
562
- ls = (0 , ls [1 ])
563
- return ls
564
- # For backcompat: (on, off, on, off, ...); the offset is implicitly None.
565
- if (_is_iterable_not_string_like (ls )
566
- and len (ls ) % 2 == 0
567
- and all (isinstance (elem , Number ) for elem in ls )):
568
- return (0 , ls )
440
+ if _is_iterable_not_string_like (ls ):
441
+ if len (ls ) == 2 and _is_iterable_not_string_like (ls [1 ]):
442
+ # (offset, (on, off, on, off, ...))
443
+ offset , onoff = ls
444
+ else :
445
+ # For backcompat: (on, off, on, off, ...); the offset is implicit.
446
+ offset = 0
447
+ onoff = ls
448
+
449
+ if (isinstance (offset , Number )
450
+ and len (onoff ) % 2 == 0
451
+ and all (isinstance (elem , Number ) for elem in onoff )):
452
+ return (offset , onoff )
453
+
569
454
raise ValueError (f"linestyle { ls !r} is not a valid on-off ink sequence." )
570
455
571
456
@@ -615,62 +500,6 @@ def validate_markevery(s):
615
500
616
501
validate_markeverylist = _listify_validator (validate_markevery )
617
502
618
- validate_legend_loc = ValidateInStrings (
619
- 'legend_loc' ,
620
- ['best' ,
621
- 'upper right' ,
622
- 'upper left' ,
623
- 'lower left' ,
624
- 'lower right' ,
625
- 'right' ,
626
- 'center left' ,
627
- 'center right' ,
628
- 'lower center' ,
629
- 'upper center' ,
630
- 'center' ], ignorecase = True , _deprecated_since = "3.3" )
631
-
632
- validate_svg_fonttype = ValidateInStrings (
633
- 'svg.fonttype' , ['none' , 'path' ], _deprecated_since = "3.3" )
634
-
635
-
636
- @_api .deprecated ("3.3" )
637
- def validate_hinting (s ):
638
- return _validate_hinting (s )
639
-
640
-
641
- # Replace by plain list in _prop_validators after deprecation period.
642
- _validate_hinting = ValidateInStrings (
643
- 'text.hinting' ,
644
- ['default' , 'no_autohint' , 'force_autohint' , 'no_hinting' ,
645
- 'auto' , 'native' , 'either' , 'none' ],
646
- ignorecase = True )
647
-
648
-
649
- validate_pgf_texsystem = ValidateInStrings (
650
- 'pgf.texsystem' , ['xelatex' , 'lualatex' , 'pdflatex' ],
651
- _deprecated_since = "3.3" )
652
-
653
-
654
- @_api .deprecated ("3.3" )
655
- def validate_movie_writer (s ):
656
- # writers.list() would only list actually available writers, but
657
- # FFMpeg.isAvailable is slow and not worth paying for at every import.
658
- if s in animation .writers ._registered :
659
- return s
660
- else :
661
- raise ValueError (f"Supported animation writers are "
662
- f"{ sorted (animation .writers ._registered )} " )
663
-
664
-
665
- validate_movie_frame_fmt = ValidateInStrings (
666
- 'animation.frame_format' , ['png' , 'jpeg' , 'tiff' , 'raw' , 'rgba' , 'ppm' ,
667
- 'sgi' , 'bmp' , 'pbm' , 'svg' ],
668
- _deprecated_since = "3.3" )
669
- validate_axis_locator = ValidateInStrings (
670
- 'major' , ['minor' , 'both' , 'major' ], _deprecated_since = "3.3" )
671
- validate_movie_html_fmt = ValidateInStrings (
672
- 'animation.html' , ['html5' , 'jshtml' , 'none' ], _deprecated_since = "3.3" )
673
-
674
503
675
504
def validate_bbox (s ):
676
505
if isinstance (s , str ):
@@ -719,10 +548,6 @@ def _validate_greaterequal0_lessequal1(s):
719
548
}
720
549
721
550
722
- validate_grid_axis = ValidateInStrings (
723
- 'axes.grid.axis' , ['x' , 'y' , 'both' ], _deprecated_since = "3.3" )
724
-
725
-
726
551
def validate_hatch (s ):
727
552
r"""
728
553
Validate a hatch pattern.
@@ -938,23 +763,6 @@ def validate_hist_bins(s):
938
763
" a sequence of floats" .format (valid_strs ))
939
764
940
765
941
- @_api .deprecated ("3.3" )
942
- def validate_webagg_address (s ):
943
- if s is not None :
944
- import socket
945
- try :
946
- socket .inet_aton (s )
947
- except socket .error as e :
948
- raise ValueError (
949
- "'webagg.address' is not a valid IP address" ) from e
950
- return s
951
- raise ValueError ("'webagg.address' is not a valid IP address" )
952
-
953
-
954
- validate_axes_titlelocation = ValidateInStrings (
955
- 'axes.titlelocation' , ['left' , 'center' , 'right' ], _deprecated_since = "3.3" )
956
-
957
-
958
766
class _ignorecase (list ):
959
767
"""A marker class indicating that a list-of-str is case-insensitive."""
960
768
@@ -1085,8 +893,9 @@ def _convert_validator_spec(key, conv):
1085
893
# text props
1086
894
"text.color" : validate_color ,
1087
895
"text.usetex" : validate_bool ,
1088
- "text.latex.preamble" : _validate_tex_preamble ,
1089
- "text.hinting" : _validate_hinting ,
896
+ "text.latex.preamble" : validate_string ,
897
+ "text.hinting" : ["default" , "no_autohint" , "force_autohint" ,
898
+ "no_hinting" , "auto" , "native" , "either" , "none" ],
1090
899
"text.hinting_factor" : validate_int ,
1091
900
"text.kerning_factor" : validate_int ,
1092
901
"text.antialiased" : validate_bool ,
@@ -1344,7 +1153,7 @@ def _convert_validator_spec(key, conv):
1344
1153
1345
1154
"pgf.texsystem" : ["xelatex" , "lualatex" , "pdflatex" ], # latex variant used
1346
1155
"pgf.rcfonts" : validate_bool , # use mpl's rc settings for font config
1347
- "pgf.preamble" : _validate_tex_preamble , # custom LaTeX preamble
1156
+ "pgf.preamble" : validate_string , # custom LaTeX preamble
1348
1157
1349
1158
# write raster image data into the svg file
1350
1159
"svg.image_inline" : validate_bool ,
0 commit comments