Skip to content

Commit 2d31dfa

Browse files
committed
Remove deprecated rcParam validators.
1 parent d82e2d4 commit 2d31dfa

File tree

4 files changed

+15
-169
lines changed

4 files changed

+15
-169
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Deprecated rcParams validators
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
The following validators, defined in `.rcsetup`, have been removed:
4+
``validate_alignment``, ``validate_axes_titlelocation``,
5+
``validate_axis_locator``, ``validate_bool_maybe_none``, ``validate_fontset``,
6+
``validate_grid_axis``, ``validate_hinting``, ``validate_legend_loc``,
7+
``validate_mathtext_default``, ``validate_movie_frame_fmt``,
8+
``validate_movie_html_fmt``, ``validate_movie_writer``,
9+
``validate_nseq_float``, ``validate_nseq_int``, ``validate_orientation``,
10+
``validate_pgf_texsystem``, ``validate_ps_papersize``,
11+
``validate_svg_fontset``, ``validate_toolbar``, ``validate_webagg_address``.

doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ The following validators, defined in `.rcsetup`, are deprecated:
238238
``validate_axes_titlelocation``, ``validate_toolbar``,
239239
``validate_ps_papersize``, ``validate_legend_loc``,
240240
``validate_bool_maybe_none``, ``validate_hinting``,
241-
``validate_movie_writers``, ``validate_webagg_address``,
241+
``validate_movie_writer``, ``validate_webagg_address``,
242242
``validate_nseq_float``, ``validate_nseq_int``.
243243
To test whether an rcParam value would be acceptable, one can test e.g. ``rc =
244244
RcParams(); rc[k] = v`` raises an exception.

lib/matplotlib/rcsetup.py

Lines changed: 3 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import numpy as np
2323

24-
from matplotlib import _api, animation, cbook
24+
from matplotlib import _api, cbook
2525
from matplotlib.cbook import ls_mapper
2626
from matplotlib.colors import Colormap, is_color_like
2727
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
@@ -146,21 +146,6 @@ def validate_bool(b):
146146
raise ValueError('Could not convert "%s" to bool' % b)
147147

148148

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-
164149
def _validate_date_converter(s):
165150
if s is None:
166151
return
@@ -303,11 +288,6 @@ def validate_backend(s):
303288
return backend
304289

305290

306-
validate_toolbar = ValidateInStrings(
307-
'toolbar', ['None', 'toolbar2', 'toolmanager'], ignorecase=True,
308-
_deprecated_since="3.3")
309-
310-
311291
def _validate_toolbar(s):
312292
s = ValidateInStrings(
313293
'toolbar', ['None', 'toolbar2', 'toolmanager'], ignorecase=True)(s)
@@ -318,42 +298,6 @@ def _validate_toolbar(s):
318298
return s
319299

320300

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-
357301
def validate_color_or_inherit(s):
358302
"""Return a valid color arg."""
359303
if cbook._str_equal(s, 'inherit'):
@@ -408,10 +352,6 @@ def _validate_cmap(s):
408352
return s
409353

410354

411-
validate_orientation = ValidateInStrings(
412-
'orientation', ['landscape', 'portrait'], _deprecated_since="3.3")
413-
414-
415355
def validate_aspect(s):
416356
if s in ('auto', 'equal'):
417357
return s
@@ -478,19 +418,6 @@ def _validate_mathtext_fallback(s):
478418
"fallback off.")
479419

480420

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-
494421
def validate_whiskers(s):
495422
try:
496423
return _listify_validator(validate_float, n=2)(s)
@@ -502,14 +429,6 @@ def validate_whiskers(s):
502429
"(float, float)]") from e
503430

504431

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-
513432
def validate_ps_distiller(s):
514433
if isinstance(s, str):
515434
s = s.lower()
@@ -615,62 +534,6 @@ def validate_markevery(s):
615534

616535
validate_markeverylist = _listify_validator(validate_markevery)
617536

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-
674537

675538
def validate_bbox(s):
676539
if isinstance(s, str):
@@ -719,10 +582,6 @@ def _validate_greaterequal0_lessequal1(s):
719582
}
720583

721584

722-
validate_grid_axis = ValidateInStrings(
723-
'axes.grid.axis', ['x', 'y', 'both'], _deprecated_since="3.3")
724-
725-
726585
def validate_hatch(s):
727586
r"""
728587
Validate a hatch pattern.
@@ -938,23 +797,6 @@ def validate_hist_bins(s):
938797
" a sequence of floats".format(valid_strs))
939798

940799

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-
958800
class _ignorecase(list):
959801
"""A marker class indicating that a list-of-str is case-insensitive."""
960802

@@ -1086,7 +928,8 @@ def _convert_validator_spec(key, conv):
1086928
"text.color": validate_color,
1087929
"text.usetex": validate_bool,
1088930
"text.latex.preamble": _validate_tex_preamble,
1089-
"text.hinting": _validate_hinting,
931+
"text.hinting": ["default", "no_autohint", "force_autohint",
932+
"no_hinting", "auto", "native", "either", "none"],
1090933
"text.hinting_factor": validate_int,
1091934
"text.kerning_factor": validate_int,
1092935
"text.antialiased": validate_bool,

lib/matplotlib/tests/test_rcparams.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import numpy as np
1717
from matplotlib.rcsetup import (
1818
validate_bool,
19-
validate_bool_maybe_none,
2019
validate_color,
2120
validate_colorlist,
2221
validate_cycler,
@@ -119,8 +118,6 @@ def test_rcparams_init():
119118

120119
def test_Bug_2543():
121120
# Test that it possible to add all values to itself / deepcopy
122-
# This was not possible because validate_bool_maybe_none did not
123-
# accept None as an argument.
124121
# https://github.com/matplotlib/matplotlib/issues/2543
125122
# We filter warnings at this stage since a number of them are raised
126123
# for deprecated rcparams as they should. We don't want these in the
@@ -132,11 +129,6 @@ def test_Bug_2543():
132129
mpl.rcParams[key] = _copy[key]
133130
with mpl.rc_context():
134131
copy.deepcopy(mpl.rcParams)
135-
# real test is that this does not raise
136-
assert validate_bool_maybe_none(None) is None
137-
assert validate_bool_maybe_none("none") is None
138-
with pytest.raises(ValueError):
139-
validate_bool_maybe_none("blah")
140132
with pytest.raises(ValueError):
141133
validate_bool(None)
142134
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)