|
3 | 3 | import logging
|
4 | 4 | import math
|
5 | 5 | from numbers import Integral, Number
|
6 |
| -from datetime import timedelta |
7 | 6 |
|
8 | 7 | import numpy as np
|
9 | 8 | from numpy import ma
|
@@ -3291,19 +3290,6 @@ def errorbar(self, x, y, yerr=None, xerr=None,
|
3291 | 3290 | if len(x) != len(y):
|
3292 | 3291 | raise ValueError("'x' and 'y' must have the same size")
|
3293 | 3292 |
|
3294 |
| - def has_negative_values(array): |
3295 |
| - if array is None: |
3296 |
| - return False |
3297 |
| - try: |
3298 |
| - return np.any(array < 0) |
3299 |
| - except TypeError: # if array contains 'datetime.timedelta' types |
3300 |
| - return np.any(array < timedelta(0)) |
3301 |
| - |
3302 |
| - if has_negative_values(xerr): |
3303 |
| - raise ValueError("'xerr' must not contain negative values") |
3304 |
| - if has_negative_values(yerr): |
3305 |
| - raise ValueError("'yerr' must not contain negative values") |
3306 |
| - |
3307 | 3293 | if isinstance(errorevery, Integral):
|
3308 | 3294 | errorevery = (0, errorevery)
|
3309 | 3295 | if isinstance(errorevery, tuple):
|
@@ -3426,6 +3412,9 @@ def apply_mask(arrays, mask): return [array[mask] for array in arrays]
|
3426 | 3412 | f"'{dep_axis}err' (shape: {np.shape(err)}) must be a "
|
3427 | 3413 | f"scalar or a 1D or (2, n) array-like whose shape matches "
|
3428 | 3414 | f"'{dep_axis}' (shape: {np.shape(dep)})") from None
|
| 3415 | + if np.any(err < -err): # like err<0, but also works for timedelta. |
| 3416 | + raise ValueError( |
| 3417 | + f"'{dep_axis}err' must not contain negative values") |
3429 | 3418 | # This is like
|
3430 | 3419 | # elow, ehigh = np.broadcast_to(...)
|
3431 | 3420 | # return dep - elow * ~lolims, dep + ehigh * ~uplims
|
|
0 commit comments