|
9 | 9 | from pandas.tests.indexes.common import Base
|
10 | 10 |
|
11 | 11 | from pandas.compat import (range, lrange, lzip, u,
|
12 |
| - text_type, zip, PY3, PY36) |
| 12 | + text_type, zip, PY3, PY36, PYPY) |
13 | 13 | import operator
|
14 | 14 | import numpy as np
|
15 | 15 |
|
@@ -1360,26 +1360,34 @@ def test_isin(self):
|
1360 | 1360 | assert len(result) == 0
|
1361 | 1361 | assert result.dtype == np.bool_
|
1362 | 1362 |
|
1363 |
| - def test_isin_nan(self): |
| 1363 | + @pytest.mark.skipif(PYPY, reason="np.nan is float('nan') on PyPy") |
| 1364 | + def test_isin_nan_not_pypy(self): |
| 1365 | + tm.assert_numpy_array_equal(Index(['a', np.nan]).isin([float('nan')]), |
| 1366 | + np.array([False, False])) |
| 1367 | + |
| 1368 | + @pytest.mark.skipif(not PYPY, reason="np.nan is float('nan') on PyPy") |
| 1369 | + def test_isin_nan_pypy(self): |
| 1370 | + tm.assert_numpy_array_equal(Index(['a', np.nan]).isin([float('nan')]), |
| 1371 | + np.array([False, True])) |
| 1372 | + |
| 1373 | + def test_isin_nan_common(self): |
1364 | 1374 | tm.assert_numpy_array_equal(Index(['a', np.nan]).isin([np.nan]),
|
1365 | 1375 | np.array([False, True]))
|
1366 | 1376 | tm.assert_numpy_array_equal(Index(['a', pd.NaT]).isin([pd.NaT]),
|
1367 | 1377 | np.array([False, True]))
|
1368 |
| - tm.assert_numpy_array_equal(Index(['a', np.nan]).isin([float('nan')]), |
1369 |
| - np.array([False, False])) |
1370 | 1378 | tm.assert_numpy_array_equal(Index(['a', np.nan]).isin([pd.NaT]),
|
1371 | 1379 | np.array([False, False]))
|
1372 | 1380 |
|
1373 | 1381 | # Float64Index overrides isin, so must be checked separately
|
1374 | 1382 | tm.assert_numpy_array_equal(Float64Index([1.0, np.nan]).isin([np.nan]),
|
1375 | 1383 | np.array([False, True]))
|
| 1384 | + # we cannot compare NaT with NaN |
| 1385 | + tm.assert_numpy_array_equal(Float64Index([1.0, np.nan]).isin([pd.NaT]), |
| 1386 | + np.array([False, False])) |
1376 | 1387 | tm.assert_numpy_array_equal(
|
1377 | 1388 | Float64Index([1.0, np.nan]).isin([float('nan')]),
|
1378 | 1389 | np.array([False, True]))
|
1379 | 1390 |
|
1380 |
| - # we cannot compare NaT with NaN |
1381 |
| - tm.assert_numpy_array_equal(Float64Index([1.0, np.nan]).isin([pd.NaT]), |
1382 |
| - np.array([False, False])) |
1383 | 1391 |
|
1384 | 1392 | def test_isin_level_kwarg(self):
|
1385 | 1393 | def check_idx(idx):
|
|
0 commit comments