Skip to content

TST: suppress some numpy warnings #15811

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

Merged
merged 2 commits into from
Mar 26, 2017
Merged
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
5 changes: 4 additions & 1 deletion pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def isin(comps, values):
" to isin(), you passed a "
"[{0}]".format(type(values).__name__))

from pandas import DatetimeIndex, PeriodIndex
from pandas import DatetimeIndex, TimedeltaIndex, PeriodIndex

if not isinstance(values, (ABCIndex, ABCSeries, np.ndarray)):
values = np.array(list(values), dtype='object')
Expand All @@ -183,6 +183,9 @@ def isin(comps, values):
if is_period_dtype(values):
comps = PeriodIndex(comps)
values = PeriodIndex(values)
elif is_timedelta64_dtype(comps):
comps = TimedeltaIndex(comps)
values = TimedeltaIndex(values)
else:
comps = DatetimeIndex(comps)
values = DatetimeIndex(values)
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ def test_basic(self):
expected = np.array([False, False])
tm.assert_numpy_array_equal(result, expected)

def test_i8(self):

arr = pd.date_range('20130101', periods=3).values
result = algos.isin(arr, [arr[0]])
expected = np.array([True, False, False])
Expand Down
6 changes: 4 additions & 2 deletions pandas/tests/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2913,10 +2913,12 @@ def test_info(self):
df['category'] = Series(np.array(list('abcdefghij')).take(
np.random.randint(0, 10, size=n))).astype('category')
df.isnull()
df.info()
buf = compat.StringIO()
df.info(buf=buf)

df2 = df[df['category'] == 'd']
df2.info()
buf = compat.StringIO()
df2.info(buf=buf)

def test_groupby_sort(self):

Expand Down
19 changes: 12 additions & 7 deletions pandas/tests/test_nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,10 @@ def test_nanstd(self):
def test_nansem(self):
tm.skip_if_no_package('scipy', min_version='0.17.0')
from scipy.stats import sem
self.check_funs_ddof(nanops.nansem, sem, allow_complex=False,
allow_str=False, allow_date=False,
allow_tdelta=True, allow_obj='convert')
with np.errstate(invalid='ignore'):
self.check_funs_ddof(nanops.nansem, sem, allow_complex=False,
allow_str=False, allow_date=False,
allow_tdelta=False, allow_obj='convert')

def _minmax_wrap(self, value, axis=None, func=None):
res = func(value, axis)
Expand Down Expand Up @@ -449,16 +450,20 @@ def test_nanskew(self):
tm.skip_if_no_package('scipy', min_version='0.17.0')
from scipy.stats import skew
func = partial(self._skew_kurt_wrap, func=skew)
self.check_funs(nanops.nanskew, func, allow_complex=False,
allow_str=False, allow_date=False, allow_tdelta=False)
with np.errstate(invalid='ignore'):
self.check_funs(nanops.nanskew, func, allow_complex=False,
allow_str=False, allow_date=False,
allow_tdelta=False)

def test_nankurt(self):
tm.skip_if_no_package('scipy', min_version='0.17.0')
from scipy.stats import kurtosis
func1 = partial(kurtosis, fisher=True)
func = partial(self._skew_kurt_wrap, func=func1)
self.check_funs(nanops.nankurt, func, allow_complex=False,
allow_str=False, allow_date=False, allow_tdelta=False)
with np.errstate(invalid='ignore'):
self.check_funs(nanops.nankurt, func, allow_complex=False,
allow_str=False, allow_date=False,
allow_tdelta=False)

def test_nanprod(self):
self.check_funs(nanops.nanprod, np.prod, allow_str=False,
Expand Down