1
1
# -*- coding: utf-8 -*-
2
2
3
3
from datetime import timedelta
4
- from distutils .version import LooseVersion
5
4
6
5
import numpy as np
7
6
import pytest
@@ -197,15 +196,13 @@ def test_ops_ndarray(self):
197
196
other = pd .to_timedelta (['1 day' ]).values
198
197
expected = pd .to_timedelta (['2 days' ]).values
199
198
tm .assert_numpy_array_equal (td + other , expected )
200
- if LooseVersion (np .__version__ ) >= LooseVersion ('1.8' ):
201
- tm .assert_numpy_array_equal (other + td , expected )
199
+ tm .assert_numpy_array_equal (other + td , expected )
202
200
pytest .raises (TypeError , lambda : td + np .array ([1 ]))
203
201
pytest .raises (TypeError , lambda : np .array ([1 ]) + td )
204
202
205
203
expected = pd .to_timedelta (['0 days' ]).values
206
204
tm .assert_numpy_array_equal (td - other , expected )
207
- if LooseVersion (np .__version__ ) >= LooseVersion ('1.8' ):
208
- tm .assert_numpy_array_equal (- other + td , expected )
205
+ tm .assert_numpy_array_equal (- other + td , expected )
209
206
pytest .raises (TypeError , lambda : td - np .array ([1 ]))
210
207
pytest .raises (TypeError , lambda : np .array ([1 ]) - td )
211
208
@@ -217,21 +214,18 @@ def test_ops_ndarray(self):
217
214
218
215
tm .assert_numpy_array_equal (td / other ,
219
216
np .array ([1 ], dtype = np .float64 ))
220
- if LooseVersion (np .__version__ ) >= LooseVersion ('1.8' ):
221
- tm .assert_numpy_array_equal (other / td ,
222
- np .array ([1 ], dtype = np .float64 ))
217
+ tm .assert_numpy_array_equal (other / td ,
218
+ np .array ([1 ], dtype = np .float64 ))
223
219
224
220
# timedelta, datetime
225
221
other = pd .to_datetime (['2000-01-01' ]).values
226
222
expected = pd .to_datetime (['2000-01-02' ]).values
227
223
tm .assert_numpy_array_equal (td + other , expected )
228
- if LooseVersion (np .__version__ ) >= LooseVersion ('1.8' ):
229
- tm .assert_numpy_array_equal (other + td , expected )
224
+ tm .assert_numpy_array_equal (other + td , expected )
230
225
231
226
expected = pd .to_datetime (['1999-12-31' ]).values
232
227
tm .assert_numpy_array_equal (- td + other , expected )
233
- if LooseVersion (np .__version__ ) >= LooseVersion ('1.8' ):
234
- tm .assert_numpy_array_equal (other - td , expected )
228
+ tm .assert_numpy_array_equal (other - td , expected )
235
229
236
230
def test_tdi_ops_attributes (self ):
237
231
rng = timedelta_range ('2 days' , periods = 5 , freq = '2D' , name = 'x' )
0 commit comments