Skip to content

Errorbar bugfix - #9242

Merged
dstansby merged 3 commits into
matplotlib:masterfrom
astromancer:errorbar-bugfix
Oct 9, 2017
Merged

dstansby merged 3 commits into
matplotlib:masterfrom
astromancer:errorbar-bugfix

Conversation

@astromancer

Copy link
Copy Markdown

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

anntzer commented Sep 27, 2017

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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