Remove asfileobj=False from a bunch of examples loading sample_data.#13621
Merged
jklymak merged 1 commit intomatplotlib:masterfrom Mar 8, 2019
Merged
Remove asfileobj=False from a bunch of examples loading sample_data.#13621jklymak merged 1 commit intomatplotlib:masterfrom
asfileobj=False from a bunch of examples loading sample_data.#13621jklymak merged 1 commit intomatplotlib:masterfrom
Conversation
anntzer
commented
Mar 7, 2019
| 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') |
Contributor
Author
There was a problem hiding this comment.
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.
tacaswell
approved these changes
Mar 8, 2019
jklymak
reviewed
Mar 8, 2019
| 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: |
Member
There was a problem hiding this comment.
I find this hard to read, but not impossible. Sure you don't want to just double-with it?
meeseeksmachine
pushed a commit
to meeseeksmachine/matplotlib
that referenced
this pull request
Mar 8, 2019
…f examples loading sample_data.
jklymak
added a commit
that referenced
this pull request
Mar 8, 2019
…621-on-v3.1.x Backport PR #13621 on branch v3.1.x (Remove `asfileobj=False` from a bunch of examples loading sample_data.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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