8000 Replace safezip() by more informative error message in errorbar(). by anntzer · Pull Request #13250 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Replace safezip() by more informative error message in errorbar(). #13250

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

Merged
merged 1 commit into from
Jan 21, 2019

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Jan 20, 2019

Currently, the error for mismatched shapes in errorbar is

ValueError: In safezip, len(args[0])=2 but len(args[1])=3

Replace it by

ValueError: The lengths of the data (2) and the error (3) do not match

and deprecate the not-so-informatively-named safezip.

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

Currently, the error for mismatched shapes in errorbar is
```
ValueError: In safezip, len(args[0])=2 but len(args[1])=3
```
Replace it by
```
ValueError: The lengths of the data (2) and the error (3) do not match
```
and deprecate the not-so-informatively-named safezip.
if len(data) != len(e):
raise ValueError(
f"The lengths of the data ({len(data)}) and the "
f"error {len(e)} do not match")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that these can be either x or y errors (they both go through this helper function) so we can't include the actual parameter names here.

Copy link
Member
@jklymak jklymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine unless someone had grandiose plans for safezip.

@tacaswell tacaswell added this to the v3.1 milestone Jan 21, 2019
@tacaswell tacaswell merged commit 8f137c3 into matplotlib:master Jan 21, 2019
@anntzer anntzer deleted the safezip branch January 21, 2019 18:12
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.

3 participants
0