Skip to content

Deprecate unused features of normalize_kwargs. #16039

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
Jan 13, 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
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,7 @@ e.g. `.FuncFormatter`.
``OldAutoLocator``
~~~~~~~~~~~~~~~~~~
This ticker is deprecated.

*required*, *forbidden* and *allowed* parameters of `.cbook.normalize_kwargs`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
These parameters are deprecated.
6 changes: 2 additions & 4 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3881,8 +3881,7 @@ def line_props_with_rcdefaults(subkey, explicit, zdelta=0,
if not use_marker:
d['marker'] = ''
if explicit is not None:
d.update(
cbook.normalize_kwargs(explicit, mlines.Line2D._alias_map))
d.update(cbook.normalize_kwargs(explicit, mlines.Line2D))
return d

# box properties
Expand All @@ -3897,8 +3896,7 @@ def line_props_with_rcdefaults(subkey, explicit, zdelta=0,
)
if boxprops is not None:
final_boxprops.update(
cbook.normalize_kwargs(
boxprops, mpatches.PathPatch._alias_map))
cbook.normalize_kwargs(boxprops, mpatches.PathPatch))
else:
final_boxprops = line_props_with_rcdefaults('boxprops', boxprops,
use_marker=False)
Expand Down
9 changes: 6 additions & 3 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,9 @@ def sanitize_sequence(data):
else data)


@_delete_parameter("3.3", "required")
@_delete_parameter("3.3", "forbidden")
@_delete_parameter("3.3", "allowed")
def normalize_kwargs(kw, alias_mapping=None, required=(), forbidden=(),
allowed=None):
"""
Expand Down Expand Up @@ -1713,16 +1716,16 @@ def normalize_kwargs(kw, alias_mapping=None, required=(), forbidden=(),
mapping.

required : list of str, optional
A list of keys that must be in *kws*.
A list of keys that must be in *kws*. This parameter is deprecated.

forbidden : list of str, optional
A list of keys which may not be in *kw*.
A list of keys which may not be in *kw*. This parameter is deprecated.

allowed : list of str, optional
A list of allowed fields. If this not None, then raise if
*kw* contains any keys not in the union of *required*
and *allowed*. To allow only the required fields pass in
an empty tuple ``allowed=()``.
an empty tuple ``allowed=()``. This parameter is deprecated.

Raises
------
Expand Down
11 changes: 5 additions & 6 deletions lib/matplotlib/tests/test_cbook.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import itertools
import pickle
from weakref import ref
import warnings
from unittest.mock import patch, Mock

from datetime import datetime
Expand Down Expand Up @@ -329,17 +328,17 @@ def test_sanitize_sequence():

@pytest.mark.parametrize('inp, kwargs_to_norm', fail_mapping)
def test_normalize_kwargs_fail(inp, kwargs_to_norm):
with pytest.raises(TypeError):
with pytest.raises(TypeError), \
cbook._suppress_matplotlib_deprecation_warning():
cbook.normalize_kwargs(inp, **kwargs_to_norm)


@pytest.mark.parametrize('inp, expected, kwargs_to_norm',
pass_mapping)
def test_normalize_kwargs_pass(inp, expected, kwargs_to_norm):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
def test_normalize_kwargs_pass(inp, expected, kwargs_to_norm, recwarn):
with cbook._suppress_matplotlib_deprecation_warning():
assert expected == cbook.normalize_kwargs(inp, **kwargs_to_norm)
assert len(w) == 0
assert len(recwarn) == 0


def test_warn_external_frame_embedded_python():
Expand Down