Skip to content

Commit 5aee26d

Browse files
authored
Merge pull request matplotlib#25469 from anntzer/unpl
Autoload numpy arrays in get_sample_data.
2 parents 72accb1 + 01e1bd9 commit 5aee26d

File tree

22 files changed

+43
-63
lines changed

22 files changed

+43
-63
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*np_load* parameter of ``cbook.get_sample_data``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
This parameter is deprecated; `.get_sample_data` now auto-loads numpy arrays.
4+
Use ``get_sample_data(..., asfileobj=False)`` instead to get the filename of
5+
the data file, which can then be passed to `open`, if desired.

galleries/examples/axes_grid1/demo_axes_divider.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414

1515
def get_demo_image():
16-
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
17-
# z is a numpy array of 15x15
16+
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy") # 15x15 array
1817
return z, (-3, 4, -4, 3)
1918

2019

galleries/examples/axes_grid1/demo_axes_grid.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
from matplotlib import cbook
1212
from mpl_toolkits.axes_grid1 import ImageGrid
1313

14-
Z = cbook.get_sample_data( # (15, 15) array
15-
"axes_grid/bivariate_normal.npy", np_load=True)
14+
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy") # 15x15 array
1615
extent = (-3, 4, -4, 3)
1716

1817

galleries/examples/axes_grid1/demo_axes_grid2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def add_inner_title(ax, title, loc, **kwargs):
2929
fig = plt.figure(figsize=(6, 6))
3030

3131
# Prepare images
32-
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
32+
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy")
3333
extent = (-3, 4, -4, 3)
3434
ZS = [Z[i::3, :] for i in range(3)]
3535
extent = extent[0], extent[1]/3., extent[2], extent[3]

galleries/examples/axes_grid1/demo_axes_rgb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
def get_rgb():
19-
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
19+
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy")
2020
Z[Z < 0] = 0.
2121
Z = Z / Z.max()
2222

galleries/examples/axes_grid1/demo_colorbar_of_inset_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
fig, ax = plt.subplots(figsize=[5, 4])
1313
ax.set(aspect=1, xlim=(-15, 15), ylim=(-20, 5))
1414

15-
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
15+
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy")
1616
extent = (-3, 4, -4, 3)
1717

1818
axins = zoomed_inset_axes(ax, zoom=2, loc='upper left')

galleries/examples/axes_grid1/demo_edge_colorbar.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515

1616
def get_demo_image():
17-
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
18-
# z is a numpy array of 15x15
17+
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy") # 15x15 array
1918
return z, (-3, 4, -4, 3)
2019

2120

galleries/examples/axes_grid1/inset_locator_demo2.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
2020
from mpl_toolkits.axes_grid1.inset_locator import mark_inset, zoomed_inset_axes
2121

22-
23-
def get_demo_image():
24-
z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
25-
# z is a numpy array of 15x15
26-
return z, (-3, 4, -4, 3)
27-
2822
fig, (ax, ax2) = plt.subplots(ncols=2, figsize=[6, 3])
2923

3024

@@ -51,9 +45,9 @@ def add_sizebar(ax, size):
5145
add_sizebar(axins, 0.5)
5246

5347

54-
# Second subplot, showing an image with an inset zoom
55-
# and a marked inset
56-
Z, extent = get_demo_image()
48+
# Second subplot, showing an image with an inset zoom and a marked inset
49+
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy") # 15x15 array
50+
extent = (-3, 4, -4, 3)
5751
Z2 = np.zeros((150, 150))
5852
ny, nx = Z.shape
5953
Z2[30:30+ny, 30:30+nx] = Z

galleries/examples/axes_grid1/simple_axesgrid2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121

2222
# demo image
23-
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy", np_load=True)
23+
Z = cbook.get_sample_data("axes_grid/bivariate_normal.npy")
2424
im1 = Z
2525
im2 = Z[:, :10]
2626
im3 = Z[:, 10:]

galleries/examples/images_contours_and_fields/shading_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def main():
2222
x, y = np.mgrid[-5:5:0.05, -5:5:0.05]
2323
z = 5 * (np.sqrt(x**2 + y**2) + np.sin(x**2 + y**2))
2424

25-
dem = cbook.get_sample_data('jacksboro_fault_dem.npz', np_load=True)
25+
dem = cbook.get_sample_data('jacksboro_fault_dem.npz')
2626
elev = dem['elevation']
2727

2828
fig = compare(z, plt.cm.copper)

0 commit comments

Comments
 (0)