Skip to content

TST: fix some scipy 0.17.0 changes #12239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pandas/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from numpy import nan
import pandas as pd

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

_skip_if_no_pchip()
import scipy
result = df.interpolate(method='pchip')
expected.ix[2, 'A'] = 3
expected.ix[5, 'A'] = 6.125

if LooseVersion(scipy.__version__) >= '0.17.0':
expected.ix[5, 'A'] = 6.0
else:
expected.ix[5, 'A'] = 6.125

assert_frame_equal(result, expected)

def test_interp_rowwise(self):
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/test_nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def check_results(self, targ, res, axis):

# timedeltas are a beast here
def _coerce_tds(targ, res):
if targ.dtype == 'm8[ns]':
if hasattr(targ, 'dtype') and targ.dtype == 'm8[ns]':
if len(targ) == 1:
targ = targ[0].item()
res = res.item()
Expand All @@ -141,7 +141,8 @@ def _coerce_tds(targ, res):
tm.assert_almost_equal(targ, res)
except:

if targ.dtype == 'm8[ns]':
# handle timedelta dtypes
if hasattr(targ, 'dtype') and targ.dtype == 'm8[ns]':
targ, res = _coerce_tds(targ, res)
tm.assert_almost_equal(targ, res)
return
Expand Down
12 changes: 11 additions & 1 deletion pandas/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pandas import compat
import nose

from distutils.version import LooseVersion
from numpy import nan
import numpy as np

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

def test_rank_methods_series(self):
tm.skip_if_no_package('scipy', '0.13', 'scipy.stats.rankdata')
import scipy
from scipy.stats import rankdata

xs = np.random.randn(9)
Expand All @@ -61,10 +63,15 @@ def test_rank_methods_series(self):
for m in ['average', 'min', 'max', 'first', 'dense']:
result = ts.rank(method=m)
sprank = rankdata(vals, m if m != 'first' else 'ordinal')
tm.assert_series_equal(result, Series(sprank, index=index))
expected = Series(sprank, index=index)

if LooseVersion(scipy.__version__) >= '0.17.0':
expected = expected.astype('float64')
tm.assert_series_equal(result, expected)

def test_rank_methods_frame(self):
tm.skip_if_no_package('scipy', '0.13', 'scipy.stats.rankdata')
import scipy
from scipy.stats import rankdata

xs = np.random.randint(0, 21, (100, 26))
Expand All @@ -81,6 +88,9 @@ def test_rank_methods_frame(self):
rankdata, ax, vals,
m if m != 'first' else 'ordinal')
expected = DataFrame(sprank, columns=cols)

if LooseVersion(scipy.__version__) >= '0.17.0':
expected = expected.astype('float64')
tm.assert_frame_equal(result, expected)

def test_rank_dense_method(self):
Expand Down