[SPARK-58249][SPARK-58234][PS][TEST][FOLLOWUP] Test native NumPy ufuncs with special values#57458
Closed
zhengruifeng wants to merge 5 commits into
Closed
Conversation
zhengruifeng
marked this pull request as ready for review
July 23, 2026 12:39
HyukjinKwon
approved these changes
Jul 24, 2026
zhengruifeng
added a commit
that referenced
this pull request
Jul 24, 2026
…cs with special values ### What changes were proposed in this pull request? Add pandas-on-Spark parity coverage for the native NumPy ufunc mappings added in #57397 and #57417. The tests compare pandas-on-Spark results with pandas/NumPy for invalid mathematical inputs, `NaN`, and positive and negative infinity. They retain the `int64` minimum-value case for `np.fabs`. ### Why are the changes needed? The mappings now execute native Spark SQL functions instead of scalar pandas UDFs. IEEE special values and invalid function domains are where the two implementations can differ, so the coverage verifies that the native results remain NumPy-compatible. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - Added pandas-on-Spark comparisons with pandas/NumPy for invalid inputs, `NaN`, and infinities. - Ran `build/sbt -Phive package`. - Ran `SPARK_TESTING=1 SPARK_PREPEND_CLASSES=1 PYSPARK_PYTHON=$CONDA_PREFIX/bin/python PYSPARK_DRIVER_PYTHON=$CONDA_PREFIX/bin/python bin/pyspark pyspark.pandas.tests.test_numpy_compat` in the `spark-dev-313` conda environment. - Ran `SPARK_TESTING=1 SPARK_PREPEND_CLASSES=1 PYSPARK_PYTHON=$CONDA_PREFIX/bin/python PYSPARK_DRIVER_PYTHON=$CONDA_PREFIX/bin/python python/run-tests --testnames "pyspark.pandas.tests.test_numpy_compat NumPyCompatTests.test_np_math_functions"` in the `spark-dev-313` conda environment. - Ran `git diff --check`. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Codex (GPT-5) Closes #57458 from zhengruifeng/pandas-native-math-special-values-dev2. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Ruifeng Zheng <ruifengz@apache.org> (cherry picked from commit 94d4715) Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add pandas-on-Spark parity coverage for the native NumPy ufunc mappings added in #57397 and #57417. The tests compare pandas-on-Spark results with pandas/NumPy for invalid mathematical inputs,
NaN, and positive and negative infinity. They retain theint64minimum-value case fornp.fabs.Why are the changes needed?
The mappings now execute native Spark SQL functions instead of scalar pandas UDFs. IEEE special values and invalid function domains are where the two implementations can differ, so the coverage verifies that the native results remain NumPy-compatible.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
NaN, and infinities.build/sbt -Phive package.SPARK_TESTING=1 SPARK_PREPEND_CLASSES=1 PYSPARK_PYTHON=$CONDA_PREFIX/bin/python PYSPARK_DRIVER_PYTHON=$CONDA_PREFIX/bin/python bin/pyspark pyspark.pandas.tests.test_numpy_compatin thespark-dev-313conda environment.SPARK_TESTING=1 SPARK_PREPEND_CLASSES=1 PYSPARK_PYTHON=$CONDA_PREFIX/bin/python PYSPARK_DRIVER_PYTHON=$CONDA_PREFIX/bin/python python/run-tests --testnames "pyspark.pandas.tests.test_numpy_compat NumPyCompatTests.test_np_math_functions"in thespark-dev-313conda environment.git diff --check.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-5)