diff --git a/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst b/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst index df34bd47dab4..a34615e18dee 100644 --- a/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst +++ b/doc/api/next_api_changes/2018-02-15-AL-deprecations.rst @@ -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: diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 52205228271e..477f4e68d918 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -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: @@ -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): @@ -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 diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index b25543ea1e20..059560ecbf45 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -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') diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index 8b28f0a1af1f..6a0040d1e0d8 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -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: diff --git a/matplotlibrc.template b/matplotlibrc.template index 6d8654d05eeb..cf777b901ec2 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -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