Skip to content

[SPARK-58553][PS][TESTS][FOLLOWUP] Skip NumPy comparison tests where NumPy's own result is platform-dependent - #58257

Closed
Spenserrrr wants to merge 1 commit into
apache:masterfrom
Spenserrrr:numpy-crossplatform-skip-tests
Closed

[SPARK-58553][PS][TESTS][FOLLOWUP] Skip NumPy comparison tests where NumPy's own result is platform-dependent#58257
Spenserrrr wants to merge 1 commit into
apache:masterfrom
Spenserrrr:numpy-crossplatform-skip-tests

Conversation

@Spenserrrr

@Spenserrrr Spenserrrr commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Skip the NumPy-comparison tests for reciprocal and fmax/fmin unless running on Linux x86-64 with NumPy >= 2.3.0, and exclude reciprocal from the random-integer sweeps (test_np_spark_compat_series / _frame) elsewhere. Test-only change; numpy_compat.py is untouched.

This is an alternative to #58019, which instead changed the implementation to fall back to pandas_udf off that platform.

Why are the changes needed?

np.reciprocal(int 0) and the fmax/fmin signed-zero tie are unspecified by C/IEEE, so NumPy's own answer varies by CPU architecture (x86-64 casts the intermediate +inf to INT64_MIN, aarch64 saturates to INT64_MAX) and by NumPy version (the scalar tie returns the first operand from 2.3.0 on, the second before).

pandas-on-Spark returns one fixed value everywhere, so NumPy is only a valid reference on the platform it was verified against. The scheduled ARM and macOS jobs fail on test_np_fmax_fmin, test_np_reciprocal_integer, and intermittently test_np_spark_compat_series.

Does this PR introduce any user-facing change?

No. Tests only.

How was this patch tested?

Existing tests. On Linux x86-64 with NumPy 2.4.1 both tests still run and pass; with platform.machine, platform.system, and np.__version__ patched to macOS arm64, Linux aarch64, and NumPy 1.23.2, they are skipped as intended.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 5

…NumPy's own result is platform-dependent

np.reciprocal(int 0) and the fmax/fmin signed-zero tie are unspecified by C/IEEE, so
NumPy's own answer varies by CPU architecture (x86-64 casts the intermediate +inf to
INT64_MIN, aarch64 saturates to INT64_MAX) and by NumPy version (the scalar tie returns
the first operand from 2.3.0 on, the second before).

pandas-on-Spark deliberately returns one fixed value on every platform, so the locally
installed NumPy is only a valid reference on the environment that value was verified
against. Skip test_np_reciprocal_integer and test_np_fmax_fmin unless running on Linux
x86-64 with NumPy >= 2.3.0, and exclude reciprocal from the random-integer sweeps there,
which fixes the scheduled ARM and macOS jobs. The implementation is unchanged.
@Spenserrrr
Spenserrrr marked this pull request as ready for review August 24, 2026 20:27
@Spenserrrr

Copy link
Copy Markdown
Contributor Author

Hi @zhengruifeng! This is the PR skipping test for fmax/fmin and reciprocal on macOS and ARM CI. Could you take a look when you have time? Thanks! cc @Yicong-Huang @HyukjinKwon

zhengruifeng pushed a commit that referenced this pull request Aug 25, 2026
…umPy's own result is platform-dependent

### What changes were proposed in this pull request?

Skip the NumPy-comparison tests for `reciprocal` and `fmax`/`fmin` unless running on Linux x86-64 with NumPy >= 2.3.0, and exclude `reciprocal` from the random-integer sweeps (`test_np_spark_compat_series` / `_frame`) elsewhere. Test-only change; `numpy_compat.py` is untouched.

This is an alternative to #58019, which instead changed the implementation to fall back to `pandas_udf` off that platform.

### Why are the changes needed?

`np.reciprocal(int 0)` and the `fmax`/`fmin` signed-zero tie are unspecified by C/IEEE, so NumPy's own answer varies by CPU architecture (x86-64 casts the intermediate `+inf` to `INT64_MIN`, aarch64 saturates to `INT64_MAX`) and by NumPy version (the scalar tie returns the first operand from 2.3.0 on, the second before).

pandas-on-Spark returns one fixed value everywhere, so NumPy is only a valid reference on the platform it was verified against. The scheduled ARM and macOS jobs fail on `test_np_fmax_fmin`, `test_np_reciprocal_integer`, and intermittently `test_np_spark_compat_series`.

### Does this PR introduce _any_ user-facing change?

No. Tests only.

### How was this patch tested?

Existing tests. On Linux x86-64 with NumPy 2.4.1 both tests still run and pass; with `platform.machine`, `platform.system`, and `np.__version__` patched to macOS arm64, Linux aarch64, and NumPy 1.23.2, they are skipped as intended.

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 5

Closes #58257 from Spenserrrr/numpy-crossplatform-skip-tests.

Authored-by: Spenser Sun <hsun112358@gmail.com>
Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
(cherry picked from commit 204a73d)
Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
@zhengruifeng

Copy link
Copy Markdown
Contributor

Merge Summary:

Posted by merge_spark_pr.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants