Skip to content

Deprecate rcParams["datapath"] in favor of mpl.get_data_path(). #16417

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

Closed
wants to merge 1 commit into from
Closed
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/removals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ rcParams
- The ``pgf.debug``, ``verbose.fileo`` and ``verbose.verbose.level`` rcParams,
which had no effect, have been removed.
- Support for setting :rc:`mathtext.default` to "circled" has been removed.
- The ``datapath`` rcParam has been removed. Use `.get_data_path` instead.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- The ``datapath`` rcParam has been removed. Use `.get_data_path` instead.
- The ``datapath`` rcParam is ignored. Use `.get_data_path` instead.


Environment variables
~~~~~~~~~~~~~~~~~~~~~
Expand Down
30 changes: 3 additions & 27 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,29 +509,8 @@ def get_cachedir():


@_logged_cached('matplotlib data path: %s')
def get_data_path(*, _from_rc=None):
def get_data_path():
"""Return the path to Matplotlib data."""
if _from_rc is not None:
cbook.warn_deprecated(
"3.2",
message=("Setting the datapath via matplotlibrc is deprecated "
"%(since)s and will be removed in %(removal)s."),
removal='3.3')
path = Path(_from_rc)
if path.is_dir():
defaultParams['datapath'][0] = str(path)
return str(path)
else:
warnings.warn(f"You passed datapath: {_from_rc!r} in your "
f"matplotribrc file ({matplotlib_fname()}). "
"However this path does not exist, falling back "
"to standard paths.")

return _get_data_path()


@_logged_cached('(private) matplotlib data path: %s')
def _get_data_path():
path = Path(__file__).with_name("mpl-data")
if path.is_dir():
defaultParams['datapath'][0] = str(path)
Expand Down Expand Up @@ -594,7 +573,7 @@ def gen_candidates():
yield matplotlibrc
yield os.path.join(matplotlibrc, 'matplotlibrc')
yield os.path.join(get_configdir(), 'matplotlibrc')
yield os.path.join(_get_data_path(), 'matplotlibrc')
yield os.path.join(get_data_path(), 'matplotlibrc')

for fname in gen_candidates():
if os.path.exists(fname) and not os.path.isdir(fname):
Expand Down Expand Up @@ -861,10 +840,7 @@ def rc_params_from_file(fname, fail_on_error=False, use_default_template=True):
config.update(config_from_file)

with cbook._suppress_matplotlib_deprecation_warning():
if config['datapath'] is None:
config['datapath'] = _get_data_path()
else:
config['datapath'] = get_data_path(_from_rc=config['datapath'])
config['datapath'] = get_data_path()

if "".join(config['text.latex.preamble']):
_log.info("""
Expand Down