|
4 | 4 | import pandas as pd |
5 | 5 | import pandas.util.testing as tm |
6 | 6 | import pytest |
7 | | -from pandas import Int64Index, MultiIndex, PeriodIndex, UInt64Index |
| 7 | +from pandas import MultiIndex |
8 | 8 | from pandas.compat import PYPY |
9 | | -from pandas.core.indexes.datetimelike import DatetimeIndexOpsMixin, iNaT |
10 | 9 |
|
11 | 10 |
|
12 | 11 | def test_contains_top_level(): |
@@ -94,37 +93,37 @@ def test_isin_level_kwarg(): |
94 | 93 | pytest.raises(KeyError, idx.isin, vals_1, level='C') |
95 | 94 |
|
96 | 95 |
|
97 | | -def test_hasnans_isnans(named_index): |
| 96 | +def test_hasnans_isnans(idx): |
98 | 97 | # GH 11343, added tests for hasnans / isnans |
99 | | - for name, index in named_index.items(): |
100 | | - if isinstance(index, MultiIndex): |
101 | | - pass |
102 | | - else: |
103 | | - idx = index.copy() |
104 | | - |
105 | | - # cases in indices doesn't include NaN |
106 | | - expected = np.array([False] * len(idx), dtype=bool) |
107 | | - tm.assert_numpy_array_equal(idx._isnan, expected) |
108 | | - assert not idx.hasnans |
109 | | - |
110 | | - idx = index.copy() |
111 | | - values = idx.values |
112 | | - |
113 | | - if len(index) == 0: |
114 | | - continue |
115 | | - elif isinstance(index, DatetimeIndexOpsMixin): |
116 | | - values[1] = iNaT |
117 | | - elif isinstance(index, (Int64Index, UInt64Index)): |
118 | | - continue |
119 | | - else: |
120 | | - values[1] = np.nan |
121 | | - |
122 | | - if isinstance(index, PeriodIndex): |
123 | | - idx = index.__class__(values, freq=index.freq) |
124 | | - else: |
125 | | - idx = index.__class__(values) |
126 | | - |
127 | | - expected = np.array([False] * len(idx), dtype=bool) |
128 | | - expected[1] = True |
129 | | - tm.assert_numpy_array_equal(idx._isnan, expected) |
130 | | - assert idx.hasnans |
| 98 | + # TODO: remove or change test not valid for MultiIndex |
| 99 | + if isinstance(idx, MultiIndex): |
| 100 | + pass |
| 101 | + # else: |
| 102 | + # _index = idx.copy() |
| 103 | + |
| 104 | + # # cases in indices doesn't include NaN |
| 105 | + # expected = np.array([False] * len(_index), dtype=bool) |
| 106 | + # tm.assert_numpy_array_equal(_index._isnan, expected) |
| 107 | + # assert not _index.hasnans |
| 108 | + |
| 109 | + # _index = idx.copy() |
| 110 | + # values = _index.values |
| 111 | + |
| 112 | + # if len(idx) == 0: |
| 113 | + # continue |
| 114 | + # elif isinstance(idx, DatetimeIndexOpsMixin): |
| 115 | + # values[1] = iNaT |
| 116 | + # elif isinstance(idx, (Int64Index, UInt64Index)): |
| 117 | + # continue |
| 118 | + # else: |
| 119 | + # values[1] = np.nan |
| 120 | + |
| 121 | + # if isinstance(idx, PeriodIndex): |
| 122 | + # _index = idx.__class__(values, freq=idx.freq) |
| 123 | + # else: |
| 124 | + # _index = idx.__class__(values) |
| 125 | + |
| 126 | + # expected = np.array([False] * len(_index), dtype=bool) |
| 127 | + # expected[1] = True |
| 128 | + # tm.assert_numpy_array_equal(_index._isnan, expected) |
| 129 | + # assert _index.hasnans |
0 commit comments