Skip to content

Commit 53941f7

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
Don't fail when np.intc != np.int32
np.intc (C int), np.int_ (C long) and np.longlong (C long long) are always distinct type objects, but only two of them are actually different sizes; np.int32 and np.int64 are aliases https://sources.debian.org/src/numpy/1:1.18.4-1/numpy/core/_type_aliases.py/#L110 Author: Rebecca N. Palmer <[email protected]> Bug: pandas-dev/pandas#31856 Forwarded: not-needed pandas-dev/pandas@1660057 Gbp-Pq: Name test_promote_32bit.patch
1 parent 9d81dbb commit 53941f7

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

pandas/tests/dtypes/cast/test_promote.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,10 @@ def _check_promote(dtype, fill_value, expected_dtype, exp_val_for_scalar=None):
9696

9797
def _assert_match(result_fill_value, expected_fill_value):
9898
# GH#23982/25425 require the same type in addition to equality/NA-ness
99-
res_type = type(result_fill_value)
100-
ex_type = type(expected_fill_value)
101-
if res_type.__name__ == "uint64":
102-
# No idea why, but these (sometimes) do not compare as equal
103-
assert ex_type.__name__ == "uint64"
104-
elif res_type.__name__ == "ulonglong":
105-
# On some builds we get this instead of np.uint64
106-
# Note: cant check res_type.dtype.itemsize directly on numpy 1.18
107-
assert res_type(0).itemsize == 8
108-
assert ex_type == res_type or ex_type == np.uint64
109-
else:
110-
# On some builds, type comparison fails, e.g. np.int32 != np.int32
111-
assert res_type == ex_type or res_type.__name__ == ex_type.__name__
99+
# use np.dtype to treat "different" scalar types
100+
# with the same data layout as equal
101+
# e.g. np.intc and np.int32, np.ulonglong and np.uint64
102+
assert np.dtype(type(result_fill_value)) == np.dtype(type(expected_fill_value))
112103

113104
match_value = result_fill_value == expected_fill_value
114105

0 commit comments

Comments
 (0)