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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/2018-01-21-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deprecations
````````````

``cbook.safezip`` is deprecated (manually check the lengths of the inputs
instead, or rely on numpy to do it).
9 changes: 7 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3200,8 +3200,13 @@ def extract_err(err, data):
raise ValueError(
"err must be a scalar or a 1D or (2, n) array-like")
# Using list comprehensions rather than arrays to preserve units.
low = [v - e for v, e in cbook.safezip(data, a)]
high = [v + e for v, e in cbook.safezip(data, b)]
for e in [a, b]:
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.

low = [v - e for v, e in zip(data, a)]
high = [v + e for v, e in zip(data, b)]
return low, high

if xerr is not None:
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ def call(command, os_name):
_safezip_msg = 'In safezip, len(args[0])=%d but len(args[%d])=%d'


@deprecated("3.1")
def safezip(*args):
"""make sure *args* are equal len before zipping"""
Nx = len(args[0])
Expand Down
0