@@ -916,16 +916,20 @@ def test_index_int64():
916916 assert repr (b [0 ]) == repr (b [np .int32 (0 )])
917917
918918
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 ):
920922 "Calling TimeArray.min() .max(), mean() should return TimeArrays"
921923 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- npt .assert_ (getattr (b , f )() == getattr (a , f )())
924+ b = ts .TimeArray (a , time_unit = tu )
925+ if f == "ptp" and ts ._NP_2 :
926+ want = np .ptp (a )
927+ else :
928+ want = getattr (a , f )()
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 )() == want )
929933
930934
931935def test_timearray_var_prod ():
0 commit comments