Skip to content
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

Remove asfileobj=False from a bunch of examples loading sample_data. #13621

Merged
merged 1 commit into from Mar 8, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 7, 2019

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

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way


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')
Copy link
Contributor Author

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.

@anntzer anntzer force-pushed the get_sample_data branch 2 times, most recently from d2ce32b to e458a46 Compare March 7, 2019 22:43
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 tacaswell added this to the v3.1.0 milestone 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:
Copy link
Member

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?

Copy link
Member

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...

@jklymak jklymak modified the milestones: v3.1.0, v3.2.0 Mar 8, 2019
@jklymak jklymak merged commit 2a282ca into matplotlib:master Mar 8, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Mar 8, 2019
@anntzer anntzer deleted the get_sample_data branch March 8, 2019 21:13
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.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants