Fix test failures on 32-bit systems
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Sun, 21 Apr 2024 12:50:13 +0000 (13:50 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sun, 21 Apr 2024 12:50:13 +0000 (13:50 +0100)
Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Bug-Debian: partly https://bugs.debian.org/1026351
Forwarded: no

Gbp-Pq: Name tests_dont_assume_64bit.patch

pandas/core/arrays/_ranges.py
pandas/tests/frame/test_stack_unstack.py
pandas/tests/groupby/test_groupby.py
pandas/tests/reshape/test_pivot.py
pandas/tests/series/methods/test_round.py
pandas/tests/test_downstream.py
pandas/tests/test_sorting.py

index 5f0409188e5e3ff0e6fdce2db062ea4bb90eeebb..5c3130aa1858acd30cd3df0be4fde6fa800343bf 100644 (file)
@@ -50,12 +50,12 @@ def generate_regular_range(
     ndarray[np.int64]
         Representing the given resolution.
     """
-    istart = start._value if start is not None else None
-    iend = end._value if end is not None else None
+    istart = int(start._value) if start is not None else None
+    iend = int(end._value) if end is not None else None
     freq.nanos  # raises if non-fixed frequency
     td = Timedelta(freq)
-    b: int | np.int64 | np.uint64
-    e: int | np.int64 | np.uint64
+    b: int
+    e: int
     try:
         td = td.as_unit(  # pyright: ignore[reportGeneralTypeIssues]
             unit, round_ok=False
@@ -98,7 +98,7 @@ def generate_regular_range(
 
 def _generate_range_overflow_safe(
     endpoint: int, periods: int, stride: int, side: str = "start"
-) -> np.int64 | np.uint64:
+) -> int:
     """
     Calculate the second endpoint for passing to np.arange, checking
     to avoid an integer overflow.  Catch OverflowError and re-raise
@@ -117,7 +117,7 @@ def _generate_range_overflow_safe(
 
     Returns
     -------
-    other_end : np.int64 | np.uint64
+    other_end : int
 
     Raises
     ------
@@ -159,13 +159,13 @@ def _generate_range_overflow_safe(
     remaining = periods - mid_periods
     assert 0 < remaining < periods, (remaining, periods, endpoint, stride)
 
-    midpoint = int(_generate_range_overflow_safe(endpoint, mid_periods, stride, side))
+    midpoint = _generate_range_overflow_safe(endpoint, mid_periods, stride, side)
     return _generate_range_overflow_safe(midpoint, remaining, stride, side)
 
 
 def _generate_range_overflow_safe_signed(
     endpoint: int, periods: int, stride: int, side: str
-) -> np.int64 | np.uint64:
+) -> int:
     """
     A special case for _generate_range_overflow_safe where `periods * stride`
     can be calculated without overflowing int64 bounds.
@@ -183,7 +183,7 @@ def _generate_range_overflow_safe_signed(
                 # Putting this into a DatetimeArray/TimedeltaArray
                 #  would incorrectly be interpreted as NaT
                 raise OverflowError
-            return result
+            return int(result)
         except (FloatingPointError, OverflowError):
             # with endpoint negative and addend positive we risk
             #  FloatingPointError; with reversed signed we risk OverflowError
@@ -202,7 +202,7 @@ def _generate_range_overflow_safe_signed(
             i64max = np.uint64(i8max)
             assert uresult > i64max
             if uresult <= i64max + np.uint64(stride):
-                return uresult
+                return int(uresult)
 
     raise OutOfBoundsDatetime(
         f"Cannot generate range with {side}={endpoint} and periods={periods}"
index dbd1f96fc17c936e79d6edc479fd4b0cd1de1c23..dbe7e661db275d198a681f4d4b3370c0af53c81d 100644 (file)
@@ -21,6 +21,7 @@ from pandas import (
 )
 import pandas._testing as tm
 from pandas.core.reshape import reshape as reshape_lib
+from pandas.compat import IS64
 
 
 @pytest.fixture(params=[True, False])
@@ -2092,6 +2093,7 @@ Thu,Lunch,Yes,51.51,17"""
         tm.assert_frame_equal(recons, df)
 
     @pytest.mark.slow
+    @pytest.mark.xfail(condition=not IS64, reason="assumes default int is int64")
     def test_unstack_number_of_levels_larger_than_int32(self, monkeypatch):
         # GH#20601
         # GH 26314: Change ValueError to PerformanceWarning
index 49ae217513018f82a92456890d3ca2f660d8ab81..33783d025dc99a94a2a748242642b9bae0d60b51 100644 (file)
@@ -5,6 +5,7 @@ import re
 import numpy as np
 import pytest
 
+from pandas.compat import IS64
 from pandas.errors import (
     PerformanceWarning,
     SpecificationError,
@@ -2545,6 +2546,7 @@ def test_groupby_series_with_tuple_name():
     tm.assert_series_equal(result, expected)
 
 
+@pytest.mark.xfail(not IS64, reason="GH#38778: fail on 32-bit system", strict=False)
 @pytest.mark.parametrize(
     "func, values", [("sum", [97.0, 98.0]), ("mean", [24.25, 24.5])]
 )
@@ -2557,6 +2559,7 @@ def test_groupby_numerical_stability_sum_mean(func, values):
     tm.assert_frame_equal(result, expected)
 
 
+@pytest.mark.xfail(not IS64, reason="GH#38778: fail on 32-bit system", strict=False)
 def test_groupby_numerical_stability_cumsum():
     # GH#38934
     data = [1e16, 1e16, 97, 98, -5e15, -5e15, -5e15, -5e15]
index 46da18445e13569b103ee23ff0afa80c9af4eb1f..c8985e838af877475f976cbe58d2c77ad02e6892 100644 (file)
@@ -26,6 +26,7 @@ import pandas._testing as tm
 from pandas.api.types import CategoricalDtype as CDT
 from pandas.core.reshape import reshape as reshape_lib
 from pandas.core.reshape.pivot import pivot_table
+from pandas.compat import IS64
 
 
 @pytest.fixture(params=[True, False])
@@ -2059,6 +2060,7 @@ class TestPivotTable:
         tm.assert_frame_equal(result, expected)
 
     @pytest.mark.slow
+    @pytest.mark.xfail(condition=not IS64, reason="assumes default int is int64")
     def test_pivot_number_of_levels_larger_than_int32(self, monkeypatch):
         # GH 20601
         # GH 26314: Change ValueError to PerformanceWarning
index 6c40e3641955122079e93007ce3d162ce66a7976..5882030b917fa2c1ce69069cf5e706ac81dc9bc0 100644 (file)
@@ -30,8 +30,7 @@ class TestSeriesRound:
     def test_round_numpy_with_nan(self, any_float_dtype):
         # See GH#14197
         ser = Series([1.53, np.nan, 0.06], dtype=any_float_dtype)
-        with tm.assert_produces_warning(None):
-            result = ser.round()
+        result = ser.round() # on armhf, numpy warns
         expected = Series([2.0, np.nan, 0.0], dtype=any_float_dtype)
         tm.assert_series_equal(result, expected)
 
index 3e74a9e44f58c627bd064e6b6d1521d164061312..cd1a7b0ccc5bd2e7a8c1705066212908c34b9ec4 100644 (file)
@@ -19,6 +19,7 @@ from pandas import (
     TimedeltaIndex,
 )
 import pandas._testing as tm
+from pandas.compat import IS64
 from pandas.core.arrays import (
     DatetimeArray,
     TimedeltaArray,
@@ -236,6 +237,11 @@ def test_missing_required_dependency():
         assert name in output
 
 
+@pytest.mark.xfail(
+    condition=not IS64,
+    reason="dask has different nativesize-int vs int64 type rules",
+    strict=False,
+)
 def test_frame_setitem_dask_array_into_new_col():
     # GH#47128
 
index 2d21d1200acac6d72879c71a8d858d4fb9c1b6ba..205c1a65ff5e2147aada00f66d4a62e01c34e537 100644 (file)
@@ -8,6 +8,7 @@ import pytest
 from pandas.compat import (
     is_ci_environment,
     is_platform_windows,
+    IS64,
 )
 
 from pandas import (
@@ -223,6 +224,7 @@ class TestMerge:
         assert result.name is None
 
     @pytest.mark.slow
+    @pytest.mark.xfail(condition=not IS64, reason="assumes default int is int64")
     @pytest.mark.parametrize("how", ["left", "right", "outer", "inner"])
     def test_int64_overflow_how_merge(self, left_right, how):
         left, right = left_right
@@ -233,6 +235,7 @@ class TestMerge:
         tm.assert_frame_equal(out, merge(left, right, how=how, sort=True))
 
     @pytest.mark.slow
+    @pytest.mark.xfail(condition=not IS64, reason="assumes default int is int64")
     def test_int64_overflow_sort_false_order(self, left_right):
         left, right = left_right
 
@@ -244,6 +247,7 @@ class TestMerge:
         tm.assert_frame_equal(right, out[right.columns.tolist()])
 
     @pytest.mark.slow
+    @pytest.mark.xfail(condition=not IS64, reason="assumes default int is int64", strict=False)
     @pytest.mark.parametrize("how", ["left", "right", "outer", "inner"])
     @pytest.mark.parametrize("sort", [True, False])
     def test_int64_overflow_one_to_many_none_match(self, how, sort):