FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #24265 on branch v3.6.x (Restore (and warn on) seaborn styles in style.library) by meeseeksmachine · Pull Request #24270 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
69 changes: 41 additions & 28 deletions lib/matplotlib/style/core.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@ class __getattr__:
'toolbar', 'timezone', 'figure.max_open_warning',
'figure.raise_window', 'savefig.directory', 'tk.window_focus',
'docstring.hardcopy', 'date.epoch'}
_DEPRECATED_SEABORN_STYLES = {
s: s.replace("seaborn", "seaborn-v0_8")
for s in [
"seaborn",
"seaborn-bright",
"seaborn-colorblind",
"seaborn-dark",
"seaborn-darkgrid",
"seaborn-dark-palette",
"seaborn-deep",
"seaborn-muted",
"seaborn-notebook",
"seaborn-paper",
"seaborn-pastel",
"seaborn-poster",
"seaborn-talk",
"seaborn-ticks",
"seaborn-white",
"seaborn-whitegrid",
]
}
_DEPRECATED_SEABORN_MSG = (
"The seaborn styles shipped by Matplotlib are deprecated since %(since)s, "
"as they no longer correspond to the styles shipped by seaborn. However, "
"they will remain available as 'seaborn-v0_8-<style>'. Alternatively, "
"directly use the seaborn API instead.")


def _remove_blacklisted_style_params(d, warn=True):
Expand Down Expand Up @@ -113,31 +139,9 @@ def use(style):
def fix_style(s):
if isinstance(s, str):
s = style_alias.get(s, s)
if s in [
"seaborn",
"seaborn-bright",
"seaborn-colorblind",
"seaborn-dark",
"seaborn-darkgrid",
"seaborn-dark-palette",
"seaborn-deep",
"seaborn-muted",
"seaborn-notebook",
"seaborn-paper",
"seaborn-pastel",
"seaborn-poster",
"seaborn-talk",
"seaborn-ticks",
"seaborn-white",
"seaborn-whitegrid",
]:
_api.warn_deprecated(
"3.6", message="The seaborn styles shipped by Matplotlib "
"are deprecated since %(since)s, as they no longer "
"correspond to the styles shipped by seaborn. However, "
"they will remain available as 'seaborn-v0_8-<style>'. "
"Alternatively, directly use the seaborn API instead.")
s = s.replace("seaborn", "seaborn-v0_8")
if s in _DEPRECATED_SEABORN_STYLES:
_api.warn_deprecated("3.6", message=_DEPRECATED_SEABORN_MSG)
s = _DEPRECATED_SEABORN_STYLES[s]
return s

for style in map(fix_style, styles):
Expand Down Expand Up @@ -244,17 +248,26 @@ def update_nested_dict(main_dict, new_dict):
return main_dict


class _StyleLibrary(dict):
def __getitem__(self, key):
if key in _DEPRECATED_SEABORN_STYLES:
_api.warn_deprecated("3.6", message=_DEPRECATED_SEABORN_MSG)
key = _DEPRECATED_SEABORN_STYLES[key]

return dict.__getitem__(self, key)


# Load style library
# ==================
_base_library = read_style_directory(BASE_LIBRARY_PATH)
library = None
library = _StyleLibrary()
available = []


def reload_library():
"""Reload the style library."""
global library
library = update_user_library(_base_library)
library.clear()
library.update(update_user_library(_base_library))
available[:] = sorted(library.keys())


Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_style.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def test_deprecated_seaborn_styles():
with pytest.warns(mpl._api.MatplotlibDeprecationWarning):
mpl.style.use("seaborn-bright")
assert mpl.rcParams == seaborn_bright
with pytest.warns(mpl._api.MatplotlibDeprecationWarning):
mpl.style.library["seaborn-bright"]


def test_up_to_date_blacklist():
Expand Down

Back | FazBrowse Home | New Git URL