Skip to content

TST: remove some more warnings #17645

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 1 commit into from
Sep 23, 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
20 changes: 1 addition & 19 deletions pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,25 +327,7 @@ def array_equivalent(left, right, strict_nan=False):
left = left.view('i8')
right = right.view('i8')

# NaNs cannot occur otherwise.
try:
return np.array_equal(left, right)
except AttributeError:
# see gh-13388
#
# NumPy v1.7.1 has a bug in its array_equal
# function that prevents it from correctly
# comparing two arrays with complex dtypes.
# This bug is corrected in v1.8.0, so remove
# this try-except block as soon as we stop
# supporting NumPy versions < 1.8.0
if not is_dtype_equal(left.dtype, right.dtype):
return False

left = left.tolist()
right = right.tolist()

return left == right
return np.array_equal(left, right)


def _infer_fill_value(val):
Expand Down
9 changes: 9 additions & 0 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,15 @@ def get_result(other):
elif is_numeric_v_string_like(values, other):
result = False

# avoid numpy warning of elementwise comparisons
elif func.__name__ == 'eq':
if is_list_like(other) and not isinstance(other, np.ndarray):
other = np.asarray(other)

# if we can broadcast, then ok
if values.shape[-1] != other.shape[-1]:
return False
result = func(values, other)
else:
result = func(values, other)

Expand Down
8 changes: 6 additions & 2 deletions pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import print_function

import warnings
from datetime import timedelta
from distutils.version import LooseVersion
import sys
Expand Down Expand Up @@ -102,7 +103,6 @@ def test_corr_int(self):
# dtypes other than float64 #1761
df3 = DataFrame({"a": [1, 2, 3, 4], "b": [1, 2, 3, 4]})

# it works!
df3.cov()
df3.corr()

Expand All @@ -117,7 +117,11 @@ def test_corr_int_and_boolean(self):
expected = DataFrame(np.ones((2, 2)), index=[
'a', 'b'], columns=['a', 'b'])
for meth in ['pearson', 'kendall', 'spearman']:
tm.assert_frame_equal(df.corr(meth), expected)

# RuntimeWarning
with warnings.catch_warnings(record=True):
result = df.corr(meth)
tm.assert_frame_equal(result, expected)

def test_corr_cov_independent_index_column(self):
# GH 14617
Expand Down
Loading