Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: re-jigger deprecation of rcParams using machinery in __init__#10379

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 1 commit intomatplotlib:masterfromtacaswell:fix_rcdeprecation
Feb 5, 2018
Merged
Show file tree
Hide file tree
Changes fromall 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
7 changes: 7 additions & 0 deletionsdoc/api/api_changes/2018-02-04-AL.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
Deprecation of qt binding rcparams
``````````````````````````````````

The :rc:`backend.qt4` and :rc:`backend.qt5` rcParams were deprecated
in version 2.2. In order to force the use of a specific Qt binding,
either import that binding first, or set the ``QT_API`` environment
variable.
17 changes: 14 additions & 3 deletionslib/matplotlib/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -848,7 +848,10 @@ def gen_candidates():
_obsolete_set = {'plugins.directory', 'text.dvipnghack'}

# The following may use a value of None to suppress the warning.
_deprecated_set = {'axes.hold'} # do NOT include in _all_deprecated
# do NOT include in _all_deprecated
_deprecated_set = {'axes.hold',
'backend.qt4',
'backend.qt5'}

_all_deprecated = set(itertools.chain(
_deprecated_ignore_map, _deprecated_map, _obsolete_set))
Expand All@@ -872,6 +875,10 @@ class RcParams(MutableMapping, dict):
msg_depr_ignore = "%s is deprecated and ignored. Use %s instead."
msg_obsolete = ("%s is obsolete. Please remove it from your matplotlibrc "
"and/or style files.")
msg_backend_obsolete = ("The {} rcParam was deprecated in version 2.2. In"
" order to force the use of a specific Qt binding,"
" either import that binding first, or set the "
"QT_API environment variable.")

# validate values on the way in
def __init__(self, *args, **kwargs):
Expand All@@ -886,8 +893,12 @@ def __setitem__(self, key, val):
key = alt_key
val = alt_val(val)
elif key in _deprecated_set and val is not None:
warnings.warn(self.msg_depr_set % key,
mplDeprecation)
if key.startswith('backend'):
warnings.warn(self.msg_backend_obsolete.format(key),
mplDeprecation)
else:
warnings.warn(self.msg_depr_set % key,
mplDeprecation)
elif key in _deprecated_ignore_map:
alt = _deprecated_ignore_map[key]
warnings.warn(self.msg_depr_ignore % (key, alt),
Expand Down
8 changes: 4 additions & 4 deletionslib/matplotlib/backends/qt_compat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -83,16 +83,16 @@
if QT_API is None:
# No ETS environment or incompatible so use rcParams.
if rcParams['backend'] == 'Qt5Agg':
QT_API =rcParams['backend.qt5']
QT_API =QT_API_PYQT5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

OK, but this does't just deprecate the rcparam, it now ignores it, right? Is that what you wanted? Feel free to clear if so, but putting a red x so its noted..

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, but the rc deprecation tools do not have a gentler option

elif rcParams['backend'] == 'Qt4Agg':
QT_API =rcParams['backend.qt4']
QT_API =QT_API_PYQT
else:
# A non-Qt backend was specified, no version of the Qt
# bindings is imported, but we still got here because a Qt
# related file was imported. This is allowed, fall back to Qt5
# using which ever binding the rparams ask for.
_fallback_to_qt4 = True
QT_API =rcParams['backend.qt5']
QT_API =QT_API_PYQT5

# We will define an appropriate wrapper for the differing versions
# of file dialog.
Expand DownExpand Up@@ -142,7 +142,7 @@
except ImportError:
if _fallback_to_qt4:
# fell through, tried PyQt5, failed fall back to PyQt4
QT_API =rcParams['backend.qt4']
QT_API =QT_API_PYQT
QT_RC_MAJOR_VERSION = 4
else:
raise
Expand Down
16 changes: 2 additions & 14 deletionslib/matplotlib/rcsetup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -268,25 +268,13 @@ def validate_backend(s):

def validate_qt4(s):
if s is None:
# return a reasonable default for deprecation period
return 'PyQt4'
cbook.warn_deprecated(
"2.2",
"The backend.qt4 rcParam was deprecated in version 2.2. In order "
"to force the use of a specific Qt4 binding, either import that "
"binding first, or set the QT_API environment variable.")
return None
return ValidateInStrings("backend.qt4", ['PyQt4', 'PySide', 'PyQt4v2'])(s)


def validate_qt5(s):
if s is None:
# return a reasonable default for deprecation period
return 'PyQt5'
cbook.warn_deprecated(
"2.2",
"The backend.qt5 rcParam was deprecated in version 2.2. In order "
"to force the use of a specific Qt5 binding, either import that "
"binding first, or set the QT_API environment variable.")
return None
return ValidateInStrings("backend.qt5", ['PyQt5', 'PySide2'])(s)


Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp