Skip to content

Commit 7a80419

Browse files
committed
test default windows int
Signed-off-by: Niels Bantilan <[email protected]>
1 parent a057df0 commit 7a80419

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

pandera/engines/pandas_engine.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,9 @@ def _register_numpy_numbers(
273273

274274
builtin_type = getattr(builtins, builtin_name, None) # uint doesn't exist
275275

276-
# default to int64 regardless of OS
277-
default_pd_dtype = {
278-
"int": np.dtype("int64"),
279-
"uint": np.dtype("uint64"),
280-
}.get(builtin_name, pd.Series([1], dtype=builtin_name).dtype)
276+
# use OS-specific type for integers. This will be int32 for Windows, int64
277+
# for other systems.
278+
default_int_dtype = pd.Series([1], dtype=builtin_name).dtype
281279

282280
for bit_width in sizes:
283281
# e.g.: numpy.int64
@@ -292,10 +290,10 @@ def _register_numpy_numbers(
292290
)
293291
)
294292

295-
if np_dtype == default_pd_dtype:
293+
if np_dtype == default_int_dtype:
296294
equivalents |= set(
297295
(
298-
default_pd_dtype,
296+
default_int_dtype,
299297
builtin_name,
300298
getattr(dtypes, pandera_name),
301299
getattr(dtypes, pandera_name)(),

tests/core/test_dtypes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import dataclasses
66
import datetime
77
import inspect
8+
import platform
89
import re
910
import sys
1011
from decimal import Decimal
@@ -507,6 +508,10 @@ def test_default_numeric_dtypes():
507508
== pandas_engine.Engine.dtype(int)
508509
== pandas_engine.Engine.dtype("int")
509510
)
511+
if platform.system() == "Windows":
512+
assert default_int_dtype == np.dtype("int32")
513+
else:
514+
assert default_int_dtype == np.dtype("int64")
510515

511516
default_float_dtype = pd.Series([1.0]).dtype
512517
assert (

0 commit comments

Comments
 (0)