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 numberOriginal file lineDiff line numberDiff line change
@@ -327,25 +327,7 @@ def array_equivalent(left, right, strict_nan=False):
327
left = left.view('i8')
327
left = left.view('i8')
328
right = right.view('i8')
328
right = right.view('i8')
329

329

330-
# NaNs cannot occur otherwise.
330+
return np.array_equal(left, right)
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
349

331

350

332

351
def _infer_fill_value(val):
333
def _infer_fill_value(val):

pandas/core/internals.py

+9
Original file line numberOriginal file lineDiff line numberDiff line change
@@ -1289,6 +1289,15 @@ def get_result(other):
1289
elif is_numeric_v_string_like(values, other):
1289
elif is_numeric_v_string_like(values, other):
1290
result = False
1290
result = False
1291

1291

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)
1292
else:
1301
else:
1293
result = func(values, other)
1302
result = func(values, other)
1294

1303

pandas/tests/frame/test_analytics.py

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

2

3
from __future__ import print_function
3
from __future__ import print_function
4

4

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

105

105-
# it works!
106
df3.cov()
106
df3.cov()
107
df3.corr()
107
df3.corr()
108

108

@@ -117,7 +117,11 @@ def test_corr_int_and_boolean(self):
117
expected = DataFrame(np.ones((2, 2)), index=[
117
expected = DataFrame(np.ones((2, 2)), index=[
118
'a', 'b'], columns=['a', 'b'])
118
'a', 'b'], columns=['a', 'b'])
119
for meth in ['pearson', 'kendall', 'spearman']:
119
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)
121

125

122
def test_corr_cov_independent_index_column(self):
126
def test_corr_cov_independent_index_column(self):
123
# GH 14617
127
# GH 14617

0 commit comments

Comments
 (0)