From a3f121e3b50d1129ea7de8d18fef76adca59c9a2 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 28 Jul 2021 01:35:31 +0200 Subject: [PATCH] Deprecate support for case-insensitive scales. ``set_xscale("LOG")`` is likely rare, and removing it avoids having to duplicate the logic if we want to support setting norms via strs. --- doc/api/next_api_changes/deprecations/20753-AL.rst | 4 ++++ lib/matplotlib/scale.py | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/20753-AL.rst diff --git a/doc/api/next_api_changes/deprecations/20753-AL.rst b/doc/api/next_api_changes/deprecations/20753-AL.rst new file mode 100644 index 000000000000..75b989f5c658 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/20753-AL.rst @@ -0,0 +1,4 @@ +Case-insensitive scales +~~~~~~~~~~~~~~~~~~~~~~~ +Previously, scales could be set case-insensitively (e.g. ``set_xscale("LoG")``). +This is deprecated; all builtin scales use lowercase names. diff --git a/lib/matplotlib/scale.py b/lib/matplotlib/scale.py index 62dc5192a30d..180906106747 100644 --- a/lib/matplotlib/scale.py +++ b/lib/matplotlib/scale.py @@ -588,9 +588,13 @@ def scale_factory(scale, axis, **kwargs): scale : {%(names)s} axis : `matplotlib.axis.Axis` """ - scale = scale.lower() - _api.check_in_list(_scale_mapping, scale=scale) - return _scale_mapping[scale](axis, **kwargs) + if scale != scale.lower(): + _api.warn_deprecated( + "3.5", message="Support for case-insensitive scales is deprecated " + "since %(since)s and support will be removed %(removal)s.") + scale = scale.lower() + scale_cls = _api.check_getitem(_scale_mapping, scale=scale) + return scale_cls(axis, **kwargs) if scale_factory.__doc__: