Skip to content

Commit 0d3d0a4

Browse files
committed
TST: fix some scipy 0.17.0 changes
partially on #12235 Author: Jeff Reback <jeff@reback.net> Closes #12239 from jreback/py35_fix and squashes the following commits: b15ec40 [Jeff Reback] TST: fix some scipy 0.17.0 changes
1 parent 59ab2ec commit 0d3d0a4

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

pandas/tests/test_generic.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from numpy import nan
77
import pandas as pd
88

9+
from distutils.version import LooseVersion
910
from pandas import (Index, Series, DataFrame, Panel, isnull,
1011
date_range, period_range)
1112
from pandas.core.index import MultiIndex
@@ -1195,9 +1196,15 @@ def test_interp_alt_scipy(self):
11951196
assert_frame_equal(result, expectedk)
11961197

11971198
_skip_if_no_pchip()
1199+
import scipy
11981200
result = df.interpolate(method='pchip')
11991201
expected.ix[2, 'A'] = 3
1200-
expected.ix[5, 'A'] = 6.125
1202+
1203+
if LooseVersion(scipy.__version__) >= '0.17.0':
1204+
expected.ix[5, 'A'] = 6.0
1205+
else:
1206+
expected.ix[5, 'A'] = 6.125
1207+
12011208
assert_frame_equal(result, expected)
12021209

12031210
def test_interp_rowwise(self):

pandas/tests/test_nanops.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def check_results(self, targ, res, axis):
122122

123123
# timedeltas are a beast here
124124
def _coerce_tds(targ, res):
125-
if targ.dtype == 'm8[ns]':
125+
if hasattr(targ, 'dtype') and targ.dtype == 'm8[ns]':
126126
if len(targ) == 1:
127127
targ = targ[0].item()
128128
res = res.item()
@@ -141,7 +141,8 @@ def _coerce_tds(targ, res):
141141
tm.assert_almost_equal(targ, res)
142142
except:
143143

144-
if targ.dtype == 'm8[ns]':
144+
# handle timedelta dtypes
145+
if hasattr(targ, 'dtype') and targ.dtype == 'm8[ns]':
145146
targ, res = _coerce_tds(targ, res)
146147
tm.assert_almost_equal(targ, res)
147148
return

pandas/tests/test_stats.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pandas import compat
33
import nose
44

5+
from distutils.version import LooseVersion
56
from numpy import nan
67
import numpy as np
78

@@ -47,6 +48,7 @@ def _check(s, expected, method='average'):
4748

4849
def test_rank_methods_series(self):
4950
tm.skip_if_no_package('scipy', '0.13', 'scipy.stats.rankdata')
51+
import scipy
5052
from scipy.stats import rankdata
5153

5254
xs = np.random.randn(9)
@@ -61,10 +63,15 @@ def test_rank_methods_series(self):
6163
for m in ['average', 'min', 'max', 'first', 'dense']:
6264
result = ts.rank(method=m)
6365
sprank = rankdata(vals, m if m != 'first' else 'ordinal')
64-
tm.assert_series_equal(result, Series(sprank, index=index))
66+
expected = Series(sprank, index=index)
67+
68+
if LooseVersion(scipy.__version__) >= '0.17.0':
69+
expected = expected.astype('float64')
70+
tm.assert_series_equal(result, expected)
6571

6672
def test_rank_methods_frame(self):
6773
tm.skip_if_no_package('scipy', '0.13', 'scipy.stats.rankdata')
74+
import scipy
6875
from scipy.stats import rankdata
6976

7077
xs = np.random.randint(0, 21, (100, 26))
@@ -81,6 +88,9 @@ def test_rank_methods_frame(self):
8188
rankdata, ax, vals,
8289
m if m != 'first' else 'ordinal')
8390
expected = DataFrame(sprank, columns=cols)
91+
92+
if LooseVersion(scipy.__version__) >= '0.17.0':
93+
expected = expected.astype('float64')
8494
tm.assert_frame_equal(result, expected)
8595

8696
def test_rank_dense_method(self):

0 commit comments

Comments
 (0)