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

Errorbar bugfix #9242

Merged
merged 3 commits into from
Oct 9, 2017
Merged

Errorbar bugfix #9242

merged 3 commits into from
Oct 9, 2017

Conversation

astromancer
Copy link
Contributor

PR Summary

Fixes #9241 by adding a filter to cbook.safe_first_element to avoid returning masked values.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 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

@anntzer
Copy link
Contributor

anntzer commented Sep 27, 2017

What happens if you pass an array that is fully masked?
I think an easier fix may be to remove the check for Sized-ness in errorbar (which is broken in this case because np.ma.masked inherits from np.ndarray (...) and thus appears as Sized (the ABC can't tell an exception is about to be thrown at C-level). Instead, use np.size(), which is much more lenient with its input (np.size(fe) at the call site).
(Strictly speaking, np.size casts its input to an array first (and then returns the product of dimensions) which may be inefficient if your input is a big non-array iterable, but on the other hand if that's the case you're about to error out -- so don't pass invalid input :-))

@astromancer
Copy link
Contributor Author

@anntzer Thanks for the comment - I've updated the PR based on your suggestions.

@dstansby dstansby added this to the 2.1.1 (next bug fix release) milestone Oct 9, 2017
@dstansby dstansby merged commit 5a0d489 into matplotlib:master Oct 9, 2017
lumberbot-app bot pushed a commit that referenced this pull request Oct 9, 2017
dstansby added a commit that referenced this pull request Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errorbar plot with first value masked raises TypeError
3 participants