[SPARK-58553][PS][FOLLOWUP] Preserve signed zero in NumPy fmax and fmin - #57819
Closed
zhengruifeng wants to merge 4 commits into
Closed
[SPARK-58553][PS][FOLLOWUP] Preserve signed zero in NumPy fmax and fmin#57819zhengruifeng wants to merge 4 commits into
zhengruifeng wants to merge 4 commits into
Conversation
uros-b
approved these changes
Aug 6, 2026
HyukjinKwon
approved these changes
Aug 6, 2026
zhengruifeng
force-pushed
the
pandas-native-fmax-fmin-followup-dev2
branch
from
August 7, 2026 05:08
97ebaf8 to
f7dd55d
Compare
zhengruifeng
marked this pull request as draft
August 7, 2026 12:00
zhengruifeng
marked this pull request as ready for review
August 7, 2026 12:21
zhengruifeng
added a commit
that referenced
this pull request
Aug 10, 2026
### What changes were proposed in this pull request? This follow-up fixes the native `np.fmax` and `np.fmin` mappings to preserve the first operand when the operands compare equal. This preserves NumPy signed-zero behavior while retaining the existing NaN handling and native Spark expressions. ### Why are the changes needed? Spark `greatest` and `least` order `-0.0` and `+0.0`, whereas NumPy retains the first operand for an equal-value tie. Consequently, the prior mapping returned the wrong signed zero for `fmax(-0.0, 0.0)` and `fmin(0.0, -0.0)`. ### Does this PR introduce _any_ user-facing change? Yes. It corrects the sign of zero for the affected `np.fmax` and `np.fmin` inputs. ### How was this patch tested? Added signbit-based regression coverage for both signed-zero operand orders. - `python/run-tests --testnames pyspark.pandas.tests.test_numpy_compat.NumPyCompatTests.test_np_fmax_fmin` - `python/run-tests --testnames pyspark.pandas.tests.connect.test_parity_numpy_compat.NumPyCompatParityTests.test_np_fmax_fmin` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Codex GPT-5 Closes #57819 from zhengruifeng/pandas-native-fmax-fmin-followup-dev2. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com> (cherry picked from commit 32a65fb) Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
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?
This follow-up fixes the native
np.fmaxandnp.fminmappings to preserve the first operand when the operands compare equal. This preserves NumPy signed-zero behavior while retaining the existing NaN handling and native Spark expressions.Why are the changes needed?
Spark
greatestandleastorder-0.0and+0.0, whereas NumPy retains the first operand for an equal-value tie. Consequently, the prior mapping returned the wrong signed zero forfmax(-0.0, 0.0)andfmin(0.0, -0.0).Does this PR introduce any user-facing change?
Yes. It corrects the sign of zero for the affected
np.fmaxandnp.fmininputs.How was this patch tested?
Added signbit-based regression coverage for both signed-zero operand orders.
python/run-tests --testnames pyspark.pandas.tests.test_numpy_compat.NumPyCompatTests.test_np_fmax_fminpython/run-tests --testnames pyspark.pandas.tests.connect.test_parity_numpy_compat.NumPyCompatParityTests.test_np_fmax_fminWas this patch authored or co-authored using generative AI tooling?
Generated-by: Codex GPT-5