Skip to content

[SPARK-58249][SPARK-58234][PS][TEST][FOLLOWUP] Test native NumPy ufuncs with special values#57458

Closed
zhengruifeng wants to merge 5 commits into
apache:masterfrom
zhengruifeng:pandas-native-math-special-values-dev2
Closed

[SPARK-58249][SPARK-58234][PS][TEST][FOLLOWUP] Test native NumPy ufuncs with special values#57458
zhengruifeng wants to merge 5 commits into
apache:masterfrom
zhengruifeng:pandas-native-math-special-values-dev2

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

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)

@zhengruifeng zhengruifeng changed the title [MINOR][PS] Test native NumPy ufuncs with special values [SPARK-58249][SPARK-58234][PS][FOLLOWUP] Test native NumPy ufuncs with special values Jul 23, 2026
@zhengruifeng zhengruifeng changed the title [SPARK-58249][SPARK-58234][PS][FOLLOWUP] Test native NumPy ufuncs with special values [SPARK-58249][SPARK-58234][PS][TEST][FOLLOWUP] Test native NumPy ufuncs with special values Jul 23, 2026
@zhengruifeng
zhengruifeng marked this pull request as ready for review July 23, 2026 12:39
@zhengruifeng
zhengruifeng requested a review from HyukjinKwon July 24, 2026 00:26
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>
@zhengruifeng

Copy link
Copy Markdown
Contributor Author

Merge Summary:

Posted by merge_spark_pr.py

@zhengruifeng
zhengruifeng deleted the pandas-native-math-special-values-dev2 branch July 24, 2026 01:32
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