File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -840,6 +840,10 @@ def is_signed_integer_dtype(arr_or_dtype) -> bool:
840
840
>>> is_signed_integer_dtype(np.array([1, 2], dtype=np.uint32)) # unsigned
841
841
False
842
842
"""
843
+ if isinstance (arr_or_dtype , type ) and issubclass (
844
+ arr_or_dtype , (np .floating , np .inexact , np .generic )
845
+ ):
846
+ return False
843
847
return _is_dtype_type (
844
848
arr_or_dtype , _classes_and_not_datetimelike (np .signedinteger )
845
849
) or _is_dtype (
Original file line number Diff line number Diff line change 17
17
is_dtype_equal ,
18
18
is_interval_dtype ,
19
19
is_period_dtype ,
20
+ is_signed_integer_dtype ,
20
21
is_string_dtype ,
21
22
)
22
23
from pandas .core .dtypes .dtypes import (
@@ -249,14 +250,10 @@ def test_alias_to_unit_raises(self):
249
250
250
251
def test_alias_to_unit_bad_alias_raises (self ):
251
252
# 23990
252
- with pytest .raises (
253
- TypeError , match = "Cannot construct a 'DatetimeTZDtype' from"
254
- ):
253
+ with pytest .raises (TypeError , match = "" ):
255
254
DatetimeTZDtype ("this is a bad string" )
256
255
257
- with pytest .raises (
258
- TypeError , match = "Cannot construct a 'DatetimeTZDtype' from"
259
- ):
256
+ with pytest .raises (TypeError , match = "" ):
260
257
DatetimeTZDtype ("datetime64[ns, US/NotATZ]" )
261
258
262
259
def test_hash_vs_equality (self , dtype ):
@@ -1150,6 +1147,13 @@ def test_is_bool_dtype(dtype, expected):
1150
1147
assert result is expected
1151
1148
1152
1149
1150
+ def test_is_signed_integer_dtype_with_abstract_types ():
1151
+ # GH 62018
1152
+ assert is_signed_integer_dtype (np .floating ) is False
1153
+ assert is_signed_integer_dtype (np .inexact ) is False
1154
+ assert is_signed_integer_dtype (np .generic ) is False
1155
+
1156
+
1153
1157
def test_is_bool_dtype_sparse ():
1154
1158
result = is_bool_dtype (Series (SparseArray ([True , False ])))
1155
1159
assert result is True
You can’t perform that action at this time.
0 commit comments