Skip to content

Commit 724cf55

Browse files
Terji PetersenTerji Petersen
Terji Petersen
authored and
Terji Petersen
committed
fix failures
1 parent 240f164 commit 724cf55

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

pandas/tests/arithmetic/test_numeric.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from datetime import timedelta
88
from decimal import Decimal
99
import operator
10-
from typing import Any
1110

1211
import numpy as np
1312
import pytest

pandas/tests/base/test_conversion.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def test_iterable(self, index_or_series, method, dtype, rdtype):
6262
# gh-13258
6363
# coerce iteration to underlying python / pandas types
6464
typ = index_or_series
65+
if dtype == "float16" and issubclass(typ, pd.Index):
66+
with pytest.raises(TypeError, match="float16 indexes are not supported"):
67+
typ([1], dtype=dtype)
68+
return
6569
s = typ([1], dtype=dtype)
6670
result = method(s)[0]
6771
assert isinstance(result, rdtype)
@@ -115,6 +119,10 @@ def test_iterable_map(self, index_or_series, dtype, rdtype):
115119
# gh-13236
116120
# coerce iteration to underlying python / pandas types
117121
typ = index_or_series
122+
if dtype == "float16" and issubclass(typ, pd.Index):
123+
with pytest.raises(TypeError, match="float16 indexes are not supported"):
124+
typ([1], dtype=dtype)
125+
return
118126
s = typ([1], dtype=dtype)
119127
result = s.map(type)[0]
120128
if not isinstance(rdtype, tuple):

pandas/tests/base/test_value_counts.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ def test_value_counts(index_or_series_obj):
2828

2929
counter = collections.Counter(obj)
3030
expected = Series(dict(counter.most_common()), dtype=np.int64, name=obj.name)
31-
expected.index = expected.index.astype(obj.dtype)
31+
32+
if obj.dtype != np.float16:
33+
expected.index = expected.index.astype(obj.dtype)
34+
else:
35+
with pytest.raises(TypeError, match="float16 indexes are not supported"):
36+
expected.index.astype(obj.dtype)
37+
return
3238

3339
if not isinstance(result.dtype, np.dtype):
3440
# i.e IntegerDtype
@@ -73,7 +79,13 @@ def test_value_counts_null(null_obj, index_or_series_obj):
7379
# np.nan would be duplicated, whereas None wouldn't
7480
counter = collections.Counter(obj.dropna())
7581
expected = Series(dict(counter.most_common()), dtype=np.int64)
76-
expected.index = expected.index.astype(obj.dtype)
82+
83+
if obj.dtype != np.float16:
84+
expected.index = expected.index.astype(obj.dtype)
85+
else:
86+
with pytest.raises(TypeError, match="float16 indexes are not supported"):
87+
expected.index.astype(obj.dtype)
88+
return
7789

7890
result = obj.value_counts()
7991
if obj.duplicated().any():

0 commit comments

Comments
 (0)