Skip to content

CI: Fix test failures in 32-bit environment #61423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

chilin0525
Copy link
Contributor

@chilin0525 chilin0525 commented May 10, 2025

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:
    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:
    >>> 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:
    >>> 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

@chilin0525
Copy link
Contributor Author

@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?

@mroeschke
Copy link
Member

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

@@ -246,7 +246,7 @@ jobs:
. ~/virtualenvs/pandas-dev/bin/activate
python -m pip install --no-cache-dir -U pip wheel setuptools meson[ninja]==1.2.1 meson-python==0.13.1
python -m pip install numpy -Csetup-args="-Dallow-noblas=true"
python -m pip install --no-cache-dir versioneer[toml] cython python-dateutil pytest>=7.3.2 pytest-xdist>=3.4.0 hypothesis>=6.84.0
python -m pip install --no-cache-dir versioneer[toml] cython==3.0.10 python-dateutil pytest>=7.3.2 pytest-xdist>=3.4.0 hypothesis>=6.84.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment somewhere here about why we're pinning Cython? The we can take this out of draft and merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've added the comment in 378ae75.

@mroeschke mroeschke added CI Continuous Integration Dependencies Required and optional dependencies 32bit 32-bit systems labels May 12, 2025
@chilin0525 chilin0525 marked this pull request as ready for review May 13, 2025 19:02
@mroeschke mroeschke added this to the 2.3 milestone May 13, 2025
@mroeschke mroeschke merged commit 41968a5 into pandas-dev:main May 13, 2025
44 checks passed
@mroeschke
Copy link
Member

Thanks @chilin0525

Copy link

lumberbot-app bot commented May 13, 2025

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
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 41968a550a159ec0e5ef541a610b7007003bab5b
  1. 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'
  1. Push to a named branch:
git push YOURFORK 2.3.x:auto-backport-of-pr-61423-on-2.3.x
  1. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
32bit 32-bit systems CI Continuous Integration Dependencies Required and optional dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants