Permalink
Browse files

Turn get_sample_data into a much simpler function that merely returns…

… files from an installed sample_data directory. Include the sample data locally. Remove sample data that is no longer used.
  • Loading branch information...
1 parent 94c53e1 commit 6c5e961080f26141a05d3f6cb2c393f4e980c910 @mdboom committed Aug 29, 2012
Showing with 6,271 additions and 329 deletions.
  1. +1 −0 MANIFEST.in
  2. +0 −27 examples/misc/sample_data_test.py
  3. +1 −1 examples/pylab_examples/centered_ticklabels.py
  4. +4 −4 examples/pylab_examples/data_helper.py
  5. +2 −4 examples/pylab_examples/image_demo2.py
  6. +2 −3 examples/pylab_examples/mri_demo.py
  7. +2 −3 examples/pylab_examples/mri_with_eeg.py
  8. +0 −14 lib/matplotlib/__init__.py
  9. +20 −259 lib/matplotlib/cbook.py
  10. BIN lib/matplotlib/mpl-data/sample_data/AAPL.dat.gz
  11. BIN lib/matplotlib/mpl-data/sample_data/INTC.dat.gz
  12. BIN lib/matplotlib/mpl-data/sample_data/Minduka_Present_Blue_Pack.png
  13. +2 −0 lib/matplotlib/mpl-data/sample_data/README.txt
  14. +6,082 −0 lib/matplotlib/mpl-data/sample_data/aapl.csv
  15. BIN lib/matplotlib/mpl-data/sample_data/aapl.npy.gz
  16. BIN lib/matplotlib/mpl-data/sample_data/axes_grid/bivariate_normal.npy
  17. BIN lib/matplotlib/mpl-data/sample_data/ct.raw.gz
  18. +11 −0 lib/matplotlib/mpl-data/sample_data/data_x_x2_x3.csv
  19. +11 −0 lib/matplotlib/mpl-data/sample_data/demodata.csv
  20. BIN lib/matplotlib/mpl-data/sample_data/eeg.dat
  21. +65 −0 lib/matplotlib/mpl-data/sample_data/embedding_in_wx3.xrc
  22. BIN lib/matplotlib/mpl-data/sample_data/goog.npy
  23. BIN lib/matplotlib/mpl-data/sample_data/lena.jpg
  24. BIN lib/matplotlib/mpl-data/sample_data/lena.png
  25. BIN lib/matplotlib/mpl-data/sample_data/logo2.png
  26. BIN lib/matplotlib/mpl-data/sample_data/membrane.dat
  27. +66 −0 lib/matplotlib/mpl-data/sample_data/msft.csv
  28. BIN lib/matplotlib/mpl-data/sample_data/s1045.ima.gz
  29. +0 −4 lib/matplotlib/rcsetup.py
  30. +0 −10 matplotlibrc.template
  31. +2 −0 setup.py
View
@@ -13,6 +13,7 @@ include lib/matplotlib/mpl-data/images/*
include lib/matplotlib/mpl-data/fonts/ttf/*
include lib/matplotlib/mpl-data/fonts/pdfcorefonts/*
include lib/matplotlib/mpl-data/fonts/afm/*
+recursive-include lib/matplotlib/mpl-data/sample_data/*
recursive-include license LICENSE*
recursive-include examples *
recursive-include doc *
@@ -1,27 +0,0 @@
-"""
-Demonstrate how get_sample_data works with git revisions in the data.
-
- git clone git@github.com/matplotlib/sample_data.git
-
-and edit testdata.csv to add a new row. After committing the changes,
-when you rerun this script you will get the updated data (and the new
-git version will be cached in ~/.matplotlib/sample_data)
-"""
-
-from __future__ import print_function
-import matplotlib.mlab as mlab
-import matplotlib.cbook as cbook
-
-# get the file handle to the cached data and print the contents
-datafile = 'testdir/subdir/testsub.csv'
-fh = cbook.get_sample_data(datafile)
-print(fh.read())
-
-# make sure we can read it using csv2rec
-fh.seek(0)
-r = mlab.csv2rec(fh)
-
-print(mlab.rec2txt(r))
-
-fh.close()
-
@@ -21,7 +21,7 @@
import matplotlib.pyplot as plt
# load some financial data; apple's stock price
-fh = cbook.get_sample_data('aapl.npy')
+fh = cbook.get_sample_data('aapl.npy.gz')
r = np.load(fh); fh.close()
r = r[-250:] # get the last 250 days
View
@@ -11,13 +11,13 @@ def get_two_stock_data():
"""
ticker1, ticker2 = 'INTC', 'AAPL'
- file1 = cbook.get_sample_data('INTC.dat', asfileobj=False)
- file2 = cbook.get_sample_data('AAPL.dat', asfileobj=False)
- M1 = fromstring( open(file1, 'rb').read(), '<d')
+ file1 = cbook.get_sample_data('INTC.dat.gz')
+ file2 = cbook.get_sample_data('AAPL.dat.gz')
+ M1 = fromstring( file1.read(), '<d')
M1 = resize(M1, (M1.shape[0]/2,2) )
- M2 = fromstring( open(file2, 'rb').read(), '<d')
+ M2 = fromstring( file2.read(), '<d')
M2 = resize(M2, (M2.shape[0]/2,2) )
d1, p1 = M1[:,0], M1[:,1]
@@ -6,9 +6,8 @@
w, h = 512, 512
-datafile = cbook.get_sample_data('ct.raw', asfileobj=False)
-print ('loading %s' % datafile)
-s = open(datafile, 'rb').read()
+datafile = cbook.get_sample_data('ct.raw.gz', asfileobj=True)
+s = datafile.read()
A = fromstring(s, uint16).astype(float)
A *= 1.0/max(A)
A.shape = w, h
@@ -35,4 +34,3 @@
setp(gca(), 'xticklabels', [])
show()
-
@@ -4,9 +4,8 @@
from pylab import *
import matplotlib.cbook as cbook
# data are 256x256 16 bit integers
-dfile = cbook.get_sample_data('s1045.ima', asfileobj=False)
-print ('loading image %s' % dfile)
-im = np.fromstring(open(dfile, 'rb').read(), np.uint16).astype(float)
+dfile = cbook.get_sample_data('s1045.ima')
+im = np.fromstring(dfile.read(), np.uint16).astype(float)
im.shape = 256, 256
#imshow(im, ColormapJet(256))
@@ -15,9 +15,8 @@
if 1: # load the data
# data are 256x256 16 bit integers
- dfile = cbook.get_sample_data('s1045.ima', asfileobj=False)
- print ('loading image %s' % dfile)
- im = np.fromstring(open(dfile, 'rb').read(), np.uint16).astype(float)
+ dfile = cbook.get_sample_data('s1045.ima.gz')
+ im = np.fromstring(dfile.read(), np.uint16).astype(float)
im.shape = 256, 256
if 1: # plot the MRI in pcolor
View
@@ -813,20 +813,6 @@ def rc_params_from_file(fname, fail_on_error=False):
# this is the instance used by the matplotlib classes
rcParams = rc_params()
-if 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
- # Sphinx requires absolute paths.
- if not os.path.isabs(rcParams['examples.directory']):
- _basedir, _fname = os.path.split(matplotlib_fname())
- # Sometimes matplotlib_fname() can return relative paths,
- # Also, using realpath() guarentees that Sphinx will use
- # the same path that matplotlib sees (in case of weird symlinks).
- _basedir = os.path.realpath(_basedir)
- _fullpath = os.path.join(_basedir, rcParams['examples.directory'])
- rcParams['examples.directory'] = _fullpath
-
rcParamsOrig = rcParams.copy()
rcParamsDefault = RcParams([ (key, default) for key, (default, converter) in \
Oops, something went wrong.

0 comments on commit 6c5e961

Please sign in to comment.