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

Skip to content

Commit f9ed276

Browse files
committed
Deprecate the examples.directory rcParam.
It is always found in the sample_data subdirectory relative to what the ``datapath`` rcParam indicates now. The latter should already provide enough flexibility for downstream packagers that want to tear the package apart...
1 parent d7bd340 commit f9ed276

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

doc/api/next_api_changes/2018-02-15-AL-deprecations.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ The following classes, methods, functions, and attributes are deprecated:
3636
- ``text.Annotation.arrow``,
3737

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

lib/matplotlib/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,10 @@ def __setitem__(self, key, val):
877877
warnings.warn(self.msg_obsolete % (key, ),
878878
mplDeprecation)
879879
return
880+
elif key == 'examples.directory':
881+
cbook.warn_deprecated(
882+
"3.0", "{} is deprecated; examples are found relative to "
883+
"the 'datapath' directory.".format(key))
880884
try:
881885
cval = self.validate[key](val)
882886
except ValueError as ve:
@@ -906,6 +910,11 @@ def __getitem__(self, key):
906910
mplDeprecation)
907911
return None
908912

913+
elif key == 'examples.directory':
914+
cbook.warn_deprecated(
915+
"3.0", "{} is deprecated; examples are found relative to the "
916+
"'datapath' directory.".format(key))
917+
909918
val = dict.__getitem__(self, key)
910919
if inverse_alt is not None:
911920
return inverse_alt(val)
@@ -1111,7 +1120,8 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
11111120
# this is the instance used by the matplotlib classes
11121121
rcParams = rc_params()
11131122

1114-
if rcParams['examples.directory']:
1123+
# Don't trigger deprecation warning when just fetching.
1124+
if dict.__getitem__(rcParams, 'examples.directory'):
11151125
# paths that are intended to be relative to matplotlib_fname()
11161126
# are allowed for the examples.directory parameter.
11171127
# However, we will need to fully qualify the path because

lib/matplotlib/cbook/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ def get_sample_data(fname, asfileobj=True):
524524
525525
If the filename ends in .gz, the file is implicitly ungzipped.
526526
"""
527-
if matplotlib.rcParams['examples.directory']:
527+
# Don't trigger deprecation warning when just fetching.
528+
if dict.__getitem__(matplotlib.rcParams, 'examples.directory'):
528529
root = matplotlib.rcParams['examples.directory']
529530
else:
530531
root = os.path.join(matplotlib._get_data_path(), 'sample_data')

lib/matplotlib/tests/test_rcparams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def test_if_rctemplate_is_up_to_date():
476476
continue
477477
if k in deprecated:
478478
continue
479-
if "verbose" in k:
479+
if k.startswith(("verbose.", "examples.directory")):
480480
continue
481481
found = False
482482
for line in rclines:

matplotlibrc.template

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,6 @@ backend : $TEMPLATE_BACKEND
594594
#keymap.all_axes : a ## enable all axes
595595
#keymap.copy : ctrl+c, cmd+c ## Copy figure to clipboard
596596

597-
## Control location of examples data files
598-
#examples.directory : ## directory to look in for custom installation
599-
600597
###ANIMATION settings
601598
#animation.html : none ## How to display the animation as HTML in
602599
## the IPython notebook. 'html5' uses

0 commit comments

Comments
 (0)