Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate the examples.directory rcParam. #11240

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
Jul 5, 2018
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
1 change: 1 addition & 0 deletions doc/api/next_api_changes/2018-02-15-AL-deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The following classes, methods, functions, and attributes are deprecated:
- ``text.Annotation.arrow``,

The following rcParams are deprecated:
- ``examples.directory`` (use ``datapath`` instead),
- ``pgf.debug`` (the pgf backend relies on logging),

The following keyword arguments are deprecated:
Expand Down
12 changes: 11 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,10 @@ def __setitem__(self, key, val):
cbook.warn_deprecated(
version, key, obj_type="rcparam", alternative=alt_key)
return
elif key == 'examples.directory':
cbook.warn_deprecated(
"3.0", "{} is deprecated; in the future, examples will be "
"found relative to the 'datapath' directory.".format(key))
try:
cval = self.validate[key](val)
except ValueError as ve:
Expand All @@ -917,6 +921,11 @@ def __getitem__(self, key):
version, key, obj_type, alternative=alt_key)
return dict.__getitem__(self, alt_key) if alt_key else None

elif key == 'examples.directory':
cbook.warn_deprecated(
"3.0", "{} is deprecated; in the future, examples will be "
"found relative to the 'datapath' directory.".format(key))

return dict.__getitem__(self, key)

def __repr__(self):
Expand Down Expand Up @@ -1116,7 +1125,8 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
# this is the instance used by the matplotlib classes
rcParams = rc_params()

if rcParams['examples.directory']:
# Don't trigger deprecation warning when just fetching.
if dict.__getitem__(rcParams, 'examples.directory'):
# paths that are intended to be relative to matplotlib_fname()
# are allowed for the examples.directory parameter.
# However, we will need to fully qualify the path because
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ def get_sample_data(fname, asfileobj=True):

If the filename ends in .gz, the file is implicitly ungzipped.
"""
if matplotlib.rcParams['examples.directory']:
# Don't trigger deprecation warning when just fetching.
if dict.__getitem__(matplotlib.rcParams, 'examples.directory'):
root = matplotlib.rcParams['examples.directory']
else:
root = os.path.join(matplotlib._get_data_path(), 'sample_data')
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def test_if_rctemplate_is_up_to_date():
continue
if k in deprecated:
continue
if "verbose" in k:
if k.startswith(("verbose.", "examples.directory")):
continue
found = False
for line in rclines:
Expand Down
3 changes: 0 additions & 3 deletions matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,6 @@ backend : $TEMPLATE_BACKEND
#keymap.all_axes : a ## enable all axes
#keymap.copy : ctrl+c, cmd+c ## Copy figure to clipboard

## Control location of examples data files
#examples.directory : ## directory to look in for custom installation

###ANIMATION settings
#animation.html : none ## How to display the animation as HTML in
## the IPython notebook. 'html5' uses
Expand Down