Skip to content

Remove deprecated rcParams. #12763

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
Feb 23, 2019
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
14 changes: 14 additions & 0 deletions doc/api/next_api_changes/2018-11-07-removals-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Removed rcParams
````````````````

The following deprecated rcParams are removed:

- ``text.dvipnghack``,
- ``nbagg.transparent`` (use :rc:`figure.facecolor` instead),
- ``plugins.directory``,
- ``axes.hold``,
- ``backend.qt4`` and ``backend.qt5`` (set the :envvar:`QT_API` environment
variable instead).

The associated validator functions ``rcsetup.validate_qt4`` and
``validate_qt5`` are deprecated.
14 changes: 1 addition & 13 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,19 +612,13 @@ def gen_candidates():
# rcParams deprecated; some can manually be mapped to another key.
# Values are tuples of (version, new_name_or_None).
_deprecated_ignore_map = {
'text.dvipnghack': ('2.1', None),
'nbagg.transparent': ('2.2', 'figure.facecolor'),
'plugins.directory': ('2.2', None),
'pgf.debug': ('3.0', None),
}

# rcParams deprecated; can use None to suppress warnings; remain actually
# listed in the rcParams (not included in _all_deprecated).
# Values are tuples of (version,)
_deprecated_remain_as_none = {
'axes.hold': ('2.1',),
'backend.qt4': ('2.2',),
'backend.qt5': ('2.2',),
'text.latex.unicode': ('3.0',),
}

Expand Down Expand Up @@ -688,14 +682,8 @@ def __setitem__(self, key, val):
val = alt_val(val)
elif key in _deprecated_remain_as_none and val is not None:
version, = _deprecated_remain_as_none[key]
addendum = ''
if key.startswith('backend'):
addendum = (
"In order to force the use of a specific Qt binding, "
"either import that binding first, or set the QT_API "
"environment variable.")
cbook.warn_deprecated(
version, name=key, obj_type="rcparam", addendum=addendum)
version, name=key, obj_type="rcparam")
elif key in _deprecated_ignore_map:
version, alt_key = _deprecated_ignore_map[key]
cbook.warn_deprecated(
Expand Down
31 changes: 12 additions & 19 deletions lib/matplotlib/backends/qt_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
The selection logic is as follows:
- if any of PyQt5, PySide2, PyQt4 or PySide have already been imported
(checked in that order), use it;
- otherwise, if the QT_API environment variable (used by Enthought) is
set, use it to determine which binding to use (but do not change the
backend based on it; i.e. if the Qt4Agg backend is requested but QT_API
is set to "pyqt5", then actually use Qt4 with the binding specified by
``rcParams["backend.qt4"]``;
- otherwise, if the QT_API environment variable (used by Enthought) is set, use
it to determine which binding to use (but do not change the backend based on
it; i.e. if the Qt5Agg backend is requested but QT_API is set to "pyqt4",
then actually use Qt5 with PyQt5 or PySide2 (whichever can be imported);
- otherwise, use whatever the rcParams indicate.
"""

Expand All @@ -33,31 +32,25 @@
# First, check if anything is already imported.
if "PyQt5" in sys.modules:
QT_API = QT_API_PYQT5
dict.__setitem__(rcParams, "backend.qt5", QT_API)
elif "PySide2" in sys.modules:
QT_API = QT_API_PYSIDE2
dict.__setitem__(rcParams, "backend.qt5", QT_API)
elif "PyQt4" in sys.modules:
QT_API = QT_API_PYQTv2
dict.__setitem__(rcParams, "backend.qt4", QT_API)
elif "PySide" in sys.modules:
QT_API = QT_API_PYSIDE
dict.__setitem__(rcParams, "backend.qt4", QT_API)
# Otherwise, check the QT_API environment variable (from Enthought). This can
# only override the binding, not the backend (in other words, we check that the
# requested backend actually matches).
elif rcParams["backend"] in ["Qt5Agg", "Qt5Cairo"]:
if QT_API_ENV == "pyqt5":
dict.__setitem__(rcParams, "backend.qt5", QT_API_PYQT5)
elif QT_API_ENV == "pyside2":
dict.__setitem__(rcParams, "backend.qt5", QT_API_PYSIDE2)
QT_API = dict.__getitem__(rcParams, "backend.qt5")
if QT_API_ENV in ["pyqt5", "pyside2"]:
QT_API = _ETS[QT_API_ENV]
else:
QT_API = None
elif rcParams["backend"] in ["Qt4Agg", "Qt4Cairo"]:
if QT_API_ENV == "pyqt4":
dict.__setitem__(rcParams, "backend.qt4", QT_API_PYQTv2)
elif QT_API_ENV == "pyside":
dict.__setitem__(rcParams, "backend.qt4", QT_API_PYSIDE)
QT_API = dict.__getitem__(rcParams, "backend.qt4")
if QT_API_ENV in ["pyqt4", "pyside"]:
QT_API = _ETS[QT_API_ENV]
else:
QT_API = None
# A non-Qt backend was selected but we still got there (possible, e.g., when
# fully manually embedding Matplotlib in a Qt app without using pyplot).
else:
Expand Down
8 changes: 2 additions & 6 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,14 @@ def validate_backend(s):
return backend


@cbook.deprecated("3.1")
def validate_qt4(s):
if s is None:
return None
return ValidateInStrings("backend.qt4", ['PyQt4', 'PySide', 'PyQt4v2'])(s)


@cbook.deprecated("3.1")
def validate_qt5(s):
if s is None:
return None
Expand Down Expand Up @@ -993,13 +995,10 @@ def _validate_linestyle(ls):
defaultParams = {
'backend': [_auto_backend_sentinel, validate_backend],
'backend_fallback': [True, validate_bool],
'backend.qt4': [None, validate_qt4],
'backend.qt5': [None, validate_qt5],
'webagg.port': [8988, validate_int],
'webagg.address': ['127.0.0.1', validate_webagg_address],
'webagg.open_in_browser': [True, validate_bool],
'webagg.port_retries': [50, validate_int],
'nbagg.transparent': [True, validate_bool],
'toolbar': ['toolbar2', validate_toolbar],
'datapath': [None, validate_path_exists], # handled by
# _get_data_path_cached
Expand Down Expand Up @@ -1129,7 +1128,6 @@ def _validate_linestyle(ls):
'text.latex.unicode': [True, validate_bool],
'text.latex.preamble': ['', _validate_tex_preamble],
'text.latex.preview': [False, validate_bool],
'text.dvipnghack': [None, validate_bool_maybe_none],
'text.hinting': ['auto', validate_hinting],
'text.hinting_factor': [8, validate_int],
'text.antialiased': [True, validate_bool],
Expand Down Expand Up @@ -1415,8 +1413,6 @@ def _validate_linestyle(ls):

# set this when you want to generate hardcopy docstring
'docstring.hardcopy': [False, validate_bool],
# where plugin directory is locate
'plugins.directory': ['.matplotlib_plugins', validate_string],

'path.simplify': [True, validate_bool],
'path.simplify_threshold': [1.0 / 9.0, ValidateInterval(0.0, 1.0)],
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def test_Bug_2543():
_copy = mpl.rcParams.copy()
for key in _copy:
mpl.rcParams[key] = _copy[key]
mpl.rcParams['text.dvipnghack'] = None
with mpl.rc_context():
_deep_copy = copy.deepcopy(mpl.rcParams)
# real test is that this does not raise
Expand Down