CI: Fix test failures in 32-bit environment
State: closed

I noticed that some CI failures are due to the same test errors appearing in several recent PRs.
After comparing multiple failed and successful CI runs, it seems that the unit tests fail when using `cython==3.1.0` in the Linux 32-bit environment.


* Faliure unittest case:
  ```python
  FAILED pandas/tests/window/test_rolling.py::test_rolling_var_numerical_issues[var-1-values0] - AssertionError: Series are different
  
  Series values are different (42.85714 %)
  [index]: [0, 1, 2, 3, 4, 5, 6]
  [left]:  [nan, 5e+33, 0.0, -1.7226268574692147e+17, -1.7226268574692147e+17, -1.7226268574692147e+17, 0.0]
  [right]: [nan, 5e+33, 0.0, 0.5, 0.5, 2.0, 0.0]
  At positional index 3, first diff: -1.7226268574692147e+17 != 0.5
  FAILED pandas/tests/window/test_rolling.py::test_rolling_var_numerical_issues[std-1-values1] - AssertionError: Series are different
  
  Series values are different (42.85714 %)
  [index]: [0, 1, 2, 3, 4, 5, 6]
  [left]:  [nan, 7.071067811865475e+16, 0.0, 0.0, 0.0, 0.0, 0.0]
  [right]: [nan, 7.071068e+16, 0.0, 0.7071068, 0.7071068, 1.414214, 0.0]
  At positional index 3, first diff: 0.0 != 0.7071068
  FAILED pandas/tests/window/test_rolling.py::test_rolling_var_numerical_issues[var-2-values2] - AssertionError: Series are different
  
  Series values are different (42.85714 %)
  [index]: [0, 1, 2, 3, 4, 5, 6]
  [left]:  [nan, 5e+33, -1.7226268574692147e+17, 0.0, -1.7226268574692147e+17, -1.7226268574692147e+17, 0.0]
  [right]: [nan, 5e+33, 0.5, 0.0, 0.5, 2.0, 0.0]
  At positional index 2, first diff: -1.7226268574692147e+17 != 0.5
  FAILED pandas/tests/window/test_rolling.py::test_rolling_var_numerical_issues[std-2-values3] - AssertionError: Series are different
  
  Series values are different (42.85714 %)
  [index]: [0, 1, 2, 3, 4, 5, 6]
  [left]:  [nan, 7.071067811865475e+16, 0.0, 0.0, 0.0, 0.0, 0.0]
  [right]: [nan, 7.071068e+16, 0.7071068, 0.0, 0.7071068, 1.414214, 0.0]
  At positional index 2, first diff: 0.0 != 0.7071068
  = 4 failed, 166839 passed, 24850 skipped, 5388 deselected, 795 xfailed, 92 xpassed, 2 warnings in 554.17s (0:09:14) =
  ```
* using `cython==3.0.10`:
  ```python
  >>> import numpy as np
  ... from pandas import Series
  ...
  ... def debug_rolling_var():
  ...     ds = Series([99999999999999999, 1, 1, 2, 3, 1, 1])
  ...     print("Rolling(2).var():\n", ds.rolling(2).var())
  ...     print("Numpy var:", np.var([99999999999999999, 1], ddof=0))
  ...
  >>> debug_rolling_var()
  Rolling(2).var():
   0             NaN
  1    5.000000e+33
  2    0.000000e+00
  3    5.000000e-01
  4    5.000000e-01
  5    2.000000e+00
  6    0.000000e+00
  dtype: float64
  Numpy var: 2.5e+33
  ```
* using `cython==3.1.0`:
  ```python
  >>> import numpy as np
  ... from pandas import Series
  ...
  ... def debug_rolling_var():
  ...     ds = Series([99999999999999999, 1, 1, 2, 3, 1, 1])
  ...     print("Rolling(2).var():\n", ds.rolling(2).var())
  ...     print("Numpy var:", np.var([99999999999999999, 1], ddof=0))
  ...
  >>> debug_rolling_var()
  Rolling(2).var():
   0             NaN
  1    5.000000e+33
  2    0.000000e+00
  3   -1.722627e+17
  4   -1.722627e+17
  5   -1.722627e+17
  6    0.000000e+00
  dtype: float64
  Numpy var: 2.5e+33
  ```

Labels:
name: CI
description: Continuous Integration
name: Dependencies
description: Required and optional dependencies
name: 32bit
description: 32-bit systems

Comments:
@mroeschke Hi, this error seems to be an upstream issue. I created this MR just to evaluate whether it's caused by Cython.
For issues like this, what's the usual approach to ensure the unit tests pass?
Thanks for starting investigation. If this is caused by Cython then we probably need to pin it like you did. If you could create a minimal example for the Cython folks (that doesn't use pandas), that'd be appreciated
Thanks @chilin0525 
Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

1. Checkout backport branch and update it.

```
git checkout 2.3.x
git pull
```

2. Cherry pick the first parent branch of the this PR on top of the older branch:
```
git cherry-pick -x -m1 41968a550a159ec0e5ef541a610b7007003bab5b
```

3. You will likely have some merge/cherry-pick conflict here, fix them and commit:

```
git commit -am 'Backport PR #61423: CI: Fix test failures in 32-bit environment'
```

4. Push to a named branch:

```
git push YOURFORK 2.3.x:auto-backport-of-pr-61423-on-2.3.x
```

5. Create a PR against branch 2.3.x, I would have named this PR:

> "Backport PR #61423 on branch 2.3.x (CI: Fix test failures in 32-bit environment)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the `Still Needs Manual Backport` label once the PR gets merged.

If these instructions are inaccurate, feel free to [suggest an improvement](https://github.com/MeeseeksBox/MeeseeksDev).