Skip to content

Commit f5abc2d

Browse files
committed
remove warning on comparision edge case
1 parent dfa0a34 commit f5abc2d

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

pandas/core/dtypes/missing.py

+4
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ def array_equivalent(left, right, strict_nan=False):
316316

317317
# NaNs can occur in float and complex arrays.
318318
if is_float_dtype(left) or is_complex_dtype(left):
319+
320+
# empty
321+
if not (np.prod(left.shape) and np.prod(right.shape)):
322+
return True
319323
return ((left == right) | (isna(left) & isna(right))).all()
320324

321325
# numpy will will not allow this type of datetimelike vs integer comparison

pandas/tests/plotting/test_misc.py

+1
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def test_parallel_coordinates(self):
206206
def test_parallel_coordinates_with_sorted_labels(self):
207207
""" For #15908 """
208208
from pandas.plotting import parallel_coordinates
209+
209210
df = DataFrame({"feat": [i for i in range(30)],
210211
"class": [2 for _ in range(10)] +
211212
[3 for _ in range(10)] +

pandas/tests/util/test_testing.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,18 @@ def test_assert_almost_equal_numbers_with_mixed(self):
4848
self._assert_not_almost_equal_both(1, [1, ])
4949
self._assert_not_almost_equal_both(1, object())
5050

51-
def test_assert_almost_equal_edge_case_ndarrays(self):
52-
self._assert_almost_equal_both(np.array([], dtype='M8[ns]'),
53-
np.array([], dtype='float64'),
54-
check_dtype=False)
55-
self._assert_almost_equal_both(np.array([], dtype=str),
56-
np.array([], dtype='int64'),
51+
@pytest.mark.parametrize(
52+
"left_dtype",
53+
['M8[ns]', 'm8[ns]', 'float64', 'int64', 'object'])
54+
@pytest.mark.parametrize(
55+
"right_dtype",
56+
['M8[ns]', 'm8[ns]', 'float64', 'int64', 'object'])
57+
def test_assert_almost_equal_edge_case_ndarrays(
58+
self, left_dtype, right_dtype):
59+
60+
# empty compare
61+
self._assert_almost_equal_both(np.array([], dtype=left_dtype),
62+
np.array([], dtype=right_dtype),
5763
check_dtype=False)
5864

5965
def test_assert_almost_equal_dicts(self):

0 commit comments

Comments
 (0)