Skip to content

Commit b53dc8f

Browse files
authored
CLN: use IS64 instead of is_platform_32bit #36108 (#36109)
1 parent b80dcbc commit b53dc8f

File tree

10 files changed

+26
-53
lines changed

10 files changed

+26
-53
lines changed

pandas/_libs/missing.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ from pandas._libs.tslibs.nattype cimport (
1818
from pandas._libs.tslibs.np_datetime cimport get_datetime64_value, get_timedelta64_value
1919

2020
from pandas._libs.ops_dispatch import maybe_dispatch_ufunc_to_dunder_op
21-
from pandas.compat import is_platform_32bit
21+
from pandas.compat import IS64
2222

2323
cdef:
2424
float64_t INF = <float64_t>np.inf
2525
float64_t NEGINF = -INF
2626

2727
int64_t NPY_NAT = util.get_nat()
2828

29-
bint is_32bit = is_platform_32bit()
29+
bint is_32bit = not IS64
3030

3131

3232
cpdef bint checknull(object val):

pandas/compat/__init__.py

+1-23
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* platform checker
99
"""
1010
import platform
11-
import struct
1211
import sys
1312
import warnings
1413

@@ -20,14 +19,6 @@
2019
IS64 = sys.maxsize > 2 ** 32
2120

2221

23-
# ----------------------------------------------------------------------------
24-
# functions largely based / taken from the six module
25-
26-
# Much of the code in this module comes from Benjamin Peterson's six library.
27-
# The license for this library can be found in LICENSES/SIX and the code can be
28-
# found at https://bitbucket.org/gutworth/six
29-
30-
3122
def set_function_name(f: F, name: str, cls) -> F:
3223
"""
3324
Bind the name/qualname attributes of the function.
@@ -38,7 +29,6 @@ def set_function_name(f: F, name: str, cls) -> F:
3829
return f
3930

4031

41-
# https://github.com/pandas-dev/pandas/pull/9123
4232
def is_platform_little_endian() -> bool:
4333
"""
4434
Checking if the running platform is little endian.
@@ -72,7 +62,7 @@ def is_platform_linux() -> bool:
7262
bool
7363
True if the running platform is linux.
7464
"""
75-
return sys.platform == "linux2"
65+
return sys.platform == "linux"
7666

7767

7868
def is_platform_mac() -> bool:
@@ -87,18 +77,6 @@ def is_platform_mac() -> bool:
8777
return sys.platform == "darwin"
8878

8979

90-
def is_platform_32bit() -> bool:
91-
"""
92-
Checking if the running platform is 32-bit.
93-
94-
Returns
95-
-------
96-
bool
97-
True if the running platform is 32-bit.
98-
"""
99-
return struct.calcsize("P") * 8 < 64
100-
101-
10280
def _import_lzma():
10381
"""
10482
Importing the `lzma` module.

pandas/tests/frame/test_api.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
import numpy as np
77
import pytest
88

9+
from pandas.compat import IS64, is_platform_windows
910
import pandas.util._test_decorators as td
1011
from pandas.util._test_decorators import async_mark, skip_if_no
1112

1213
import pandas as pd
13-
from pandas import Categorical, DataFrame, Series, compat, date_range, timedelta_range
14+
from pandas import Categorical, DataFrame, Series, date_range, timedelta_range
1415
import pandas._testing as tm
1516

1617

@@ -254,7 +255,7 @@ def test_itertuples(self, float_frame):
254255
assert list(dfaa.itertuples()) == [(0, 1, 1), (1, 2, 2), (2, 3, 3)]
255256

256257
# repr with int on 32-bit/windows
257-
if not (compat.is_platform_windows() or compat.is_platform_32bit()):
258+
if not (is_platform_windows() or not IS64):
258259
assert (
259260
repr(list(df.itertuples(name=None)))
260261
== "[(0, 1, 4), (1, 2, 5), (2, 3, 6)]"

pandas/tests/indexes/interval/test_interval_tree.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import pytest
55

66
from pandas._libs.interval import IntervalTree
7+
from pandas.compat import IS64
78

8-
from pandas import compat
99
import pandas._testing as tm
1010

1111

@@ -14,9 +14,7 @@ def skipif_32bit(param):
1414
Skip parameters in a parametrize on 32bit systems. Specifically used
1515
here to skip leaf_size parameters related to GH 23440.
1616
"""
17-
marks = pytest.mark.skipif(
18-
compat.is_platform_32bit(), reason="GH 23440: int type mismatch on 32bit"
19-
)
17+
marks = pytest.mark.skipif(not IS64, reason="GH 23440: int type mismatch on 32bit")
2018
return pytest.param(param, marks=marks)
2119

2220

@@ -181,7 +179,7 @@ def test_is_overlapping_trivial(self, closed, left, right):
181179
tree = IntervalTree(left, right, closed=closed)
182180
assert tree.is_overlapping is False
183181

184-
@pytest.mark.skipif(compat.is_platform_32bit(), reason="GH 23440")
182+
@pytest.mark.skipif(not IS64, reason="GH 23440")
185183
def test_construction_overflow(self):
186184
# GH 25485
187185
left, right = np.arange(101, dtype="int64"), [np.iinfo(np.int64).max] * 101

pandas/tests/indexing/test_coercion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pytest
77

8-
import pandas.compat as compat
8+
from pandas.compat import IS64, is_platform_windows
99

1010
import pandas as pd
1111
import pandas._testing as tm
@@ -1041,7 +1041,7 @@ def test_replace_series(self, how, to_key, from_key):
10411041
from_key == "complex128" and to_key in ("int64", "float64")
10421042
):
10431043

1044-
if compat.is_platform_32bit() or compat.is_platform_windows():
1044+
if not IS64 or is_platform_windows():
10451045
pytest.skip(f"32-bit platform buggy: {from_key} -> {to_key}")
10461046

10471047
# Expected: do not downcast by replacement

pandas/tests/io/formats/test_format.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import pytest
1919
import pytz
2020

21-
from pandas.compat import is_platform_32bit, is_platform_windows
21+
from pandas.compat import IS64, is_platform_windows
2222
import pandas.util._test_decorators as td
2323

2424
import pandas as pd
@@ -41,7 +41,7 @@
4141
import pandas.io.formats.format as fmt
4242
import pandas.io.formats.printing as printing
4343

44-
use_32bit_repr = is_platform_windows() or is_platform_32bit()
44+
use_32bit_repr = is_platform_windows() or not IS64
4545

4646

4747
@pytest.fixture(params=["string", "pathlike", "buffer"])

pandas/tests/io/json/test_pandas.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010
import pytest
1111

12-
from pandas.compat import is_platform_32bit, is_platform_windows
12+
from pandas.compat import IS64, is_platform_windows
1313
import pandas.util._test_decorators as td
1414

1515
import pandas as pd
@@ -154,7 +154,7 @@ def test_roundtrip_intframe(self, orient, convert_axes, numpy, dtype, int_frame)
154154
expected = int_frame
155155
if (
156156
numpy
157-
and (is_platform_32bit() or is_platform_windows())
157+
and (not IS64 or is_platform_windows())
158158
and not dtype
159159
and orient != "split"
160160
):
@@ -361,9 +361,7 @@ def test_frame_infinity(self, orient, inf, dtype):
361361
result = read_json(df.to_json(), dtype=dtype)
362362
assert np.isnan(result.iloc[0, 2])
363363

364-
@pytest.mark.skipif(
365-
is_platform_32bit(), reason="not compliant on 32-bit, xref #15865"
366-
)
364+
@pytest.mark.skipif(not IS64, reason="not compliant on 32-bit, xref #15865")
367365
@pytest.mark.parametrize(
368366
"value,precision,expected_val",
369367
[

pandas/tests/io/json/test_ujson.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import pandas._libs.json as ujson
1717
from pandas._libs.tslib import Timestamp
18-
import pandas.compat as compat
18+
from pandas.compat import IS64, is_platform_windows
1919

2020
from pandas import DataFrame, DatetimeIndex, Index, NaT, Series, Timedelta, date_range
2121
import pandas._testing as tm
@@ -53,7 +53,7 @@ def get_int32_compat_dtype(numpy, orient):
5353
# See GH#32527
5454
dtype = np.int64
5555
if not ((numpy is None or orient == "index") or (numpy is True and orient is None)):
56-
if compat.is_platform_windows():
56+
if is_platform_windows():
5757
dtype = np.int32
5858
else:
5959
dtype = np.intp
@@ -62,9 +62,7 @@ def get_int32_compat_dtype(numpy, orient):
6262

6363

6464
class TestUltraJSONTests:
65-
@pytest.mark.skipif(
66-
compat.is_platform_32bit(), reason="not compliant on 32-bit, xref #15865"
67-
)
65+
@pytest.mark.skipif(not IS64, reason="not compliant on 32-bit, xref #15865")
6866
def test_encode_decimal(self):
6967
sut = decimal.Decimal("1337.1337")
7068
encoded = ujson.encode(sut, double_precision=15)
@@ -561,7 +559,7 @@ def test_encode_long_conversion(self):
561559
assert long_input == ujson.decode(output)
562560

563561
@pytest.mark.parametrize("bigNum", [sys.maxsize + 1, -(sys.maxsize + 2)])
564-
@pytest.mark.xfail(not compat.IS64, reason="GH-35288")
562+
@pytest.mark.xfail(not IS64, reason="GH-35288")
565563
def test_dumps_ints_larger_than_maxsize(self, bigNum):
566564
# GH34395
567565
bigNum = sys.maxsize + 1
@@ -703,7 +701,7 @@ def test_int_array(self, any_int_dtype):
703701
tm.assert_numpy_array_equal(arr_input, arr_output)
704702

705703
def test_int_max(self, any_int_dtype):
706-
if any_int_dtype in ("int64", "uint64") and compat.is_platform_32bit():
704+
if any_int_dtype in ("int64", "uint64") and not IS64:
707705
pytest.skip("Cannot test 64-bit integer on 32-bit platform")
708706

709707
klass = np.dtype(any_int_dtype).type

pandas/tests/test_algos.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from pandas._libs import algos as libalgos, hashtable as ht
1010
from pandas._libs.groupby import group_var_float32, group_var_float64
11+
from pandas.compat import IS64
1112
from pandas.compat.numpy import np_array_datetime64_compat
1213
import pandas.util._test_decorators as td
1314

@@ -29,7 +30,6 @@
2930
IntervalIndex,
3031
Series,
3132
Timestamp,
32-
compat,
3333
)
3434
import pandas._testing as tm
3535
import pandas.core.algorithms as algos
@@ -1137,7 +1137,7 @@ def test_dropna(self):
11371137
)
11381138

11391139
# 32-bit linux has a different ordering
1140-
if not compat.is_platform_32bit():
1140+
if IS64:
11411141
result = Series([10.3, 5.0, 5.0, None]).value_counts(dropna=False)
11421142
expected = Series([2, 1, 1], index=[5.0, 10.3, np.nan])
11431143
tm.assert_series_equal(result, expected)
@@ -1170,7 +1170,7 @@ def test_value_counts_uint64(self):
11701170
result = algos.value_counts(arr)
11711171

11721172
# 32-bit linux has a different ordering
1173-
if not compat.is_platform_32bit():
1173+
if IS64:
11741174
tm.assert_series_equal(result, expected)
11751175

11761176

pandas/util/_test_decorators.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_foo():
3131
import numpy as np
3232
import pytest
3333

34-
from pandas.compat import is_platform_32bit, is_platform_windows
34+
from pandas.compat import IS64, is_platform_windows
3535
from pandas.compat._optional import import_optional_dependency
3636
from pandas.compat.numpy import _np_version
3737

@@ -180,7 +180,7 @@ def skip_if_no(package: str, min_version: Optional[str] = None):
180180
_skip_if_no_mpl(), reason="Missing matplotlib dependency"
181181
)
182182
skip_if_mpl = pytest.mark.skipif(not _skip_if_no_mpl(), reason="matplotlib is present")
183-
skip_if_32bit = pytest.mark.skipif(is_platform_32bit(), reason="skipping for 32 bit")
183+
skip_if_32bit = pytest.mark.skipif(not IS64, reason="skipping for 32 bit")
184184
skip_if_windows = pytest.mark.skipif(is_platform_windows(), reason="Running on Windows")
185185
skip_if_windows_python_3 = pytest.mark.skipif(
186186
is_platform_windows(), reason="not used on win32"

0 commit comments

Comments
 (0)