8000 Merge pull request #13250 from anntzer/safezip · matplotlib/matplotlib@8f137c3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f137c3

Browse files
authored
Merge pull request #13250 from anntzer/safezip
API: Replace safezip() by more informative error message in errorbar().
2 parents d44d567 + 30ef0b5 commit 8f137c3

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
``cbook.safezip`` is deprecated (manually check the lengths of the inputs
5+
instead, or rely on numpy to do it).

lib/matplotlib/axes/_axes.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3200,8 +3200,13 @@ def extract_err(err, data):
32003200
raise ValueError(
32013201
"err must be a scalar or a 1D or (2, n) array-like")
32023202
# Using list comprehensions rather than arrays to preserve units.
3203-
low = [v - e for v, e in cbook.safezip(data, a)]
3204-
high = [v + e for v, e in cbook.safezip(data, b)]
3203+
for e in [a, b]:
3204+
if len(data) != len(e):
3205+
raise ValueError(
3206+
f"The lengths of the data ({len(data)}) and the "
3207+
f"error {len(e)} do not match")
3208+
low = [v - e for v, e in zip(data, a)]
3209+
high = [v + e for v, e in zip(data, b)]
32053210
return low, high
32063211

32073212
if xerr is not None:

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ def call(command, os_name):
776776
_safezip_msg = 'In safezip, len(args[0])=%d but len(args[%d])=%d'
777777

778778

779+
@deprecated("3.1")
779780
def safezip(*args):
780781
"""make sure *args* are equal len before zipping"""
781782
Nx = len(args[0])

0 commit comments

Comments
 (0)
0