-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Remove asfileobj=False
from a bunch of examples loading sample_data.
#13621
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
Conversation
|
||
fig, ax = plt.subplots() | ||
|
||
ax.plot(np.random.rand(20), '-o', ms=20, lw=2, alpha=0.7, mfc='orange') | ||
ax.plot(np.sin(10 * np.linspace(0, 1)), '-o', ms=20, alpha=0.7, mfc='orange') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the actual data here doesn't really matter, so let's not bother with seeding an rng.
d2ce32b
to
e458a46
Compare
Using a file object works just fine. There are some more examples that use genfromtxt, but their conversion effectively needs numpy>=1.14 per https://github.com/numpy/numpy/blob/master/doc/release/1.14.0-notes.rst#encoding-argument-for-text-io-functions There are some more examples that load bivariate_normal.npy, but they have a bunch of duplicated code that could use some more refactor.
filename = cbook.get_sample_data('jacksboro_fault_dem.npz', asfileobj=False) | ||
with np.load(filename) as dem: | ||
with cbook.get_sample_data('jacksboro_fault_dem.npz') as file, \ | ||
np.load(file) as dem: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this hard to read, but not impossible. Sure you don't want to just double-with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tacaswell approves so I guess its good...
…f examples loading sample_data.
…621-on-v3.1.x Backport PR #13621 on branch v3.1.x (Remove `asfileobj=False` from a bunch of examples loading sample_data.)
Using a file object works just fine.
There are some more examples that use genfromtxt, but their conversion
effectively needs numpy>=1.14 per
https://github.com/numpy/numpy/blob/master/doc/release/1.14.0-notes.rst#encoding-argument-for-text-io-functions
There are some more examples that load bivariate_normal.npy, but they
have a bunch of duplicated code that could use some more refactor.
PR Summary
PR Checklist