8000 get_sample_data() in cbook.py duplicates code from _get_data_path() __init__.py · Issue #6536 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
get_sample_data() in cbook.py duplicates code from _get_data_path() __init__.py #6536
Closed
@rathann

Description

@rathann

To help us understand and resolve your issue please check that you have provided
the information below.

  • Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)

1.5.2rc2, python 2.7.11 and python 3.5.1, Fedora rawhide.

  • How did you install Matplotlib and Python (pip, anaconda, from source ...)

From source, I'm building a new version of the Fedora package.

  • If possible please supply a Short, Self Contained, Correct, Example
    that demonstrates the issue i.e a small piece of code which reproduces the issue
    and can be run with out any other (or as few as possible) external dependencies.

In Fedora, we're patching the lib/matplotlib/__init__.py to use /usr/share/matplotlib/mpl-data as the path for data files. cbook.py seems to have its own reimplementation of the data files path code, so the path needs to be patched in two locations. It would be nice if we could specify the desired data files location path at build time, by the way. Shall I open a separate issue for that?

Trivial patch:

--- a/lib/matplotlib/cbook.py   2016-05-20 14:14:52.000000000 +0200
+++ b/lib/matplotlib/cbook.py   2016-05-20 19:28:57.373601582 +0200
@@ -823,8 +823,7 @@ def get_sample_data(fname, asfileobj=Tru
     if matplotlib.rcParams['examples.directory']:
         root = matplotlib.rcParams['examples.directory']
     else:
-        root = os.path.join(os.path.dirname(__file__),
-                            "mpl-data", "sample_data")
+        root = os.path.join(matplotlib._get_data_path(), 'sample_data')
     path = os.path.join(root, fname)

     if asfileobj:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0