@@ -916,20 +916,20 @@ def test_index_int64():
916
916
assert repr (b [0 ]) == repr (b [np .int32 (0 )])
917
917
918
918
919
- def test_timearray_math_functions ():
919
+ @pytest .mark .parametrize ('f' , ['min' , 'max' , 'mean' , 'ptp' , 'sum' ])
920
+ @pytest .mark .parametrize ('tu' , ['s' , 'ms' , 'ps' , 'D' ])
921
+ def test_timearray_math_functions (f , tu ):
920
922
"Calling TimeArray.min() .max(), mean() should return TimeArrays"
921
923
a = np .arange (2 , 11 )
922
- for f in ['min' , 'max' , 'mean' , 'ptp' , 'sum' ]:
923
- for tu in ['s' , 'ms' , 'ps' , 'D' ]:
924
- b = ts .TimeArray (a , time_unit = tu )
925
- npt .assert_ (getattr (b , f )().__class__ == ts .TimeArray )
926
- npt .assert_ (getattr (b , f )().time_unit == b .time_unit )
927
- # comparison with unitless should convert to the TimeArray's units
928
- if f == "ptp" :
929
- want = np .ptp (a ) # ndarray.ptp removed in 2.0
930
- else :
931
- want = getattr (a , f )()
932
- npt .assert_ (getattr (b , f )() == want )
924
+ b = ts .TimeArray (a , time_unit = tu )
925
+ if f == "ptp" and ts ._NP_2 :
926
+ with pytest .raises (AttributeError , match = '`ptp` was removed' ):
927
+ a .ptp () # ndarray.ptp removed in 2.0
928
+ return
929
+ npt .assert_ (getattr (b , f )().__class__ == ts .TimeArray )
930
+ npt .assert_ (getattr (b , f )().time_unit == b .time_unit )
931
+ # comparison with unitless should convert to the TimeArray's units
932
+ npt .assert_ (getattr (b , f )() == getattr (a , f )())
933
933
934
934
935
935
def test_timearray_var_prod ():
0 commit comments