Skip to content

Commit fd0e959

Browse files
Terji PetersenTerji Petersen
Terji Petersen
authored and
Terji Petersen
committed
make NumericIndex fail with float16 dtype, II
1 parent a173ea8 commit fd0e959

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

pandas/tests/arithmetic/test_numeric.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,10 @@ def compare_op(series, other, op):
7272
# TODO: remove this kludge once mypy stops giving false positives here
7373
# List comprehension has incompatible type List[PandasObject]; expected List[RangeIndex]
7474
# See GH#29725
75-
ser_or_index: list[Any] = [Series, Index]
76-
lefts: list[Any] = [RangeIndex(10, 40, 10)]
77-
lefts.extend(
78-
[
79-
cls([10, 20, 30], dtype=dtype)
80-
for dtype in ["i1", "i2", "i4", "i8", "u1", "u2", "u4", "u8", "f2", "f4", "f8"]
81-
for cls in ser_or_index
82-
]
83-
)
75+
_ldtypes = ["i1", "i2", "i4", "i8", "u1", "u2", "u4", "u8", "f2", "f4", "f8"]
76+
lefts: list[Index | Series] = [RangeIndex(10, 40, 10)]
77+
lefts.extend([Series([10, 20, 30], dtype=dtype) for dtype in _ldtypes])
78+
lefts.extend([Index([10, 20, 30], dtype=dtype) for dtype in _ldtypes if dtype != "f2"])
8479

8580
# ------------------------------------------------------------------
8681
# Comparisons

pandas/tests/indexes/numeric/test_numeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ class TestFloat16Index:
558558
def test_array(self):
559559
arr = np.array([1, 2, 3], dtype=np.float16)
560560
with pytest.raises(TypeError, match="float16 indexes are not supported"):
561-
result = NumericIndex(arr)
561+
NumericIndex(arr)
562562

563563

564564
class TestUIntNumericIndex(NumericInt):

0 commit comments

Comments
 (0)