File tree 2 files changed +9
-2
lines changed 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 3
3
import logging
4
4
import math
5
5
from numbers import Integral , Number
6
+ from datetime import timedelta
6
7
7
8
import numpy as np
8
9
from numpy import ma
@@ -3289,8 +3290,8 @@ def has_negative_values(array):
3289
3290
return False
3290
3291
try :
3291
3292
return np .any (array < 0 )
3292
- except TypeError :
3293
- pass # Don't fail on 'datetime.*' types
3293
+ except TypeError : # if array contains 'datetime.timedelta' types
3294
+ return np . any ( array < timedelta ( 0 ))
3294
3295
3295
3296
if has_negative_values (xerr ) or has_negative_values (yerr ):
3296
3297
raise ValueError (
Original file line number Diff line number Diff line change @@ -3524,6 +3524,12 @@ def test_xerr_yerr_positive():
3524
3524
ax .errorbar (x = [0 ], y = [0 ], xerr = [[- 0.5 ], [1 ]])
3525
3525
with pytest .raises (ValueError , match = error_message ):
3526
3526
ax .errorbar (x = [0 ], y = [0 ], yerr = [[- 0.5 ], [1 ]])
3527
+ with pytest .raises (ValueError , match = error_message ):
3528
+ x = np .arange (5 )
3529
+ y = [datetime .datetime (2021 , 9 , i * 2 + 1 ) for i in x ]
3530
+ ax .errorbar (x = x ,
3531
+ y = y ,
3532
+ yerr = datetime .timedelta (days = - 10 ))
3527
3533
3528
3534
3529
3535
@check_figures_equal ()
You can’t perform that action at this time.
0 commit comments