Skip to content

Commit cbb5f18

Browse files
committed
fix various issues reported by the CI
1 parent a4a2aa5 commit cbb5f18

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def _outer_indexer(
358358
_comparables = ["name"]
359359
_attributes = ["name"]
360360
_is_numeric_dtype = False
361-
_can_hold_na = True
361+
_can_hold_na: bool = True
362362
_can_hold_strings = True
363363

364364
# would we like our indexing holder to defer to us

pandas/core/indexes/numeric.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
Dtype,
1717
DtypeObj,
1818
)
19-
from pandas.util._decorators import doc
19+
from pandas.util._decorators import (
20+
cache_readonly,
21+
doc,
22+
)
2023

2124
from pandas.core.dtypes.cast import astype_nansafe
2225
from pandas.core.dtypes.common import (
@@ -382,7 +385,7 @@ class NumIndex(NumericIndex):
382385
_default_dtype: np.dtype
383386
_dtype_validation_metadata = (is_numeric_dtype, "numeric type")
384387

385-
@property
388+
@cache_readonly
386389
def _can_hold_na(self) -> bool:
387390
if is_integer_dtype(self.dtype):
388391
return False

pandas/tests/base/test_unique.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def test_unique(index_or_series_obj):
2424
expected = pd.MultiIndex.from_tuples(unique_values)
2525
expected.names = obj.names
2626
tm.assert_index_equal(result, expected)
27+
elif isinstance(obj, pd.NumIndex):
28+
expected = pd.NumIndex(unique_values, dtype=obj.dtype)
29+
tm.assert_index_equal(result, expected)
2730
elif isinstance(obj, pd.Index):
2831
expected = pd.Index(unique_values, dtype=obj.dtype)
2932
if is_datetime64tz_dtype(obj.dtype):
@@ -62,7 +65,10 @@ def test_unique_null(null_obj, index_or_series_obj):
6265
unique_values_not_null = [val for val in unique_values_raw if not pd.isnull(val)]
6366
unique_values = [null_obj] + unique_values_not_null
6467

65-
if isinstance(obj, pd.Index):
68+
if isinstance(obj, pd.NumIndex):
69+
expected = pd.NumIndex(unique_values, dtype=obj.dtype)
70+
tm.assert_index_equal(result, expected)
71+
elif isinstance(obj, pd.Index):
6672
expected = pd.Index(unique_values, dtype=obj.dtype)
6773
if is_datetime64tz_dtype(obj.dtype):
6874
result = result.normalize()

0 commit comments

Comments
 (0)