Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate more rc validators. #16604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,11 @@ The following validators, defined in `.rcsetup`, are deprecated:
``validate_movie_frame_fmt``, ``validate_axis_locator``,
``validate_movie_html_fmt``, ``validate_grid_axis``,
``validate_axes_titlelocation``, ``validate_toolbar``,
``validate_ps_papersize``, ``validate_legend_log``. To test whether an rcParam
value would be acceptable, one can test e.g. ``rc = RcParams(); rc[k] = v``
raises an exception.
``validate_ps_papersize``, ``validate_legend_loc``,
``validate_bool_maybe_none``, ``validate_hinting``,
``validate_movie_writers``.
To test whether an rcParam value would be acceptable, one can test e.g. ``rc =
RcParams(); rc[k] = v`` raises an exception.

Toggling axes navigation from the keyboard using "a" and digit keys
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
12 changes: 10 additions & 2 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def validate_bool(b):
raise ValueError('Could not convert "%s" to bool' % b)


@cbook.deprecated("3.3")
def validate_bool_maybe_none(b):
"""Convert b to ``bool`` or raise, passing through *None*."""
if isinstance(b, str):
Expand Down Expand Up @@ -646,7 +647,13 @@ def validate_markevery(s):
'svg.fonttype', ['none', 'path'], _deprecated_since="3.3")


@cbook.deprecated("3.3")
def validate_hinting(s):
return _validate_hinting(s)


# Replace by plain list in _prop_validators after deprecation period.
def _validate_hinting(s):
if s in (True, False):
cbook.warn_deprecated(
"3.2", message="Support for setting the text.hinting rcParam to "
Expand All @@ -663,6 +670,7 @@ def validate_hinting(s):
_deprecated_since="3.3")


@cbook.deprecated("3.3")
def validate_movie_writer(s):
# writers.list() would only list actually available writers, but
# FFMpeg.isAvailable is slow and not worth paying for at every import.
Expand Down Expand Up @@ -1133,7 +1141,7 @@ def _convert_validator_spec(key, conv):
'text.usetex': [False, validate_bool],
'text.latex.preamble': ['', _validate_tex_preamble],
'text.latex.preview': [False, validate_bool],
'text.hinting': ['auto', validate_hinting],
'text.hinting': ['auto', _validate_hinting],
'text.hinting_factor': [8, validate_int],
'text.kerning_factor': [0, validate_int],
'text.antialiased': [True, validate_bool],
Expand Down Expand Up @@ -1452,7 +1460,7 @@ def _convert_validator_spec(key, conv):
# Limit, in MB, of size of base64 encoded animation in HTML
# (i.e. IPython notebook)
'animation.embed_limit': [20, validate_float],
'animation.writer': ['ffmpeg', validate_movie_writer],
'animation.writer': ['ffmpeg', validate_string],
'animation.codec': ['h264', validate_string],
'animation.bitrate': [-1, validate_int],
# Controls image format when frames are written to disk
Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ def test_Bug_2543():
# real test is that this does not raise
assert validate_bool_maybe_none(None) is None
assert validate_bool_maybe_none("none") is None

with pytest.raises(ValueError):
validate_bool_maybe_none("blah")
with pytest.raises(ValueError):
validate_bool_maybe_none("blah")
with pytest.raises(ValueError):
validate_bool(None)
with pytest.raises(ValueError):
Expand Down