Skip to content

Commit ecd2ad9

Browse files
authored
TST: remove some more warnings (#17645)
TST: parametrize stata tests
1 parent 2eb568a commit ecd2ad9

File tree

6 files changed

+189
-187
lines changed

6 files changed

+189
-187
lines changed

pandas/core/dtypes/missing.py

+1-19
Original file line numberDiff line numberDiff line change
@@ -327,25 +327,7 @@ def array_equivalent(left, right, strict_nan=False):
327327
left = left.view('i8')
328328
right = right.view('i8')
329329

330-
# NaNs cannot occur otherwise.
331-
try:
332-
return np.array_equal(left, right)
333-
except AttributeError:
334-
# see gh-13388
335-
#
336-
# NumPy v1.7.1 has a bug in its array_equal
337-
# function that prevents it from correctly
338-
# comparing two arrays with complex dtypes.
339-
# This bug is corrected in v1.8.0, so remove
340-
# this try-except block as soon as we stop
341-
# supporting NumPy versions < 1.8.0
342-
if not is_dtype_equal(left.dtype, right.dtype):
343-
return False
344-
345-
left = left.tolist()
346-
right = right.tolist()
347-
348-
return left == right
330+
return np.array_equal(left, right)
349331

350332

351333
def _infer_fill_value(val):

pandas/core/internals.py

+9
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,15 @@ def get_result(other):
12891289
elif is_numeric_v_string_like(values, other):
12901290
result = False
12911291

1292+
# avoid numpy warning of elementwise comparisons
1293+
elif func.__name__ == 'eq':
1294+
if is_list_like(other) and not isinstance(other, np.ndarray):
1295+
other = np.asarray(other)
1296+
1297+
# if we can broadcast, then ok
1298+
if values.shape[-1] != other.shape[-1]:
1299+
return False
1300+
result = func(values, other)
12921301
else:
12931302
result = func(values, other)
12941303

pandas/tests/frame/test_analytics.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import print_function
44

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

105-
# it works!
106106
df3.cov()
107107
df3.corr()
108108

@@ -117,7 +117,11 @@ def test_corr_int_and_boolean(self):
117117
expected = DataFrame(np.ones((2, 2)), index=[
118118
'a', 'b'], columns=['a', 'b'])
119119
for meth in ['pearson', 'kendall', 'spearman']:
120-
tm.assert_frame_equal(df.corr(meth), expected)
120+
121+
# RuntimeWarning
122+
with warnings.catch_warnings(record=True):
123+
result = df.corr(meth)
124+
tm.assert_frame_equal(result, expected)
121125

122126
def test_corr_cov_independent_index_column(self):
123127
# GH 14617

0 commit comments

Comments
 (0)