[SPARK-58553][PS][FOLLOWUP] Preserve signed zero in NumPy fmax and fmin - #57819
Open
zhengruifeng wants to merge 3 commits into
Open
[SPARK-58553][PS][FOLLOWUP] Preserve signed zero in NumPy fmax and fmin#57819zhengruifeng wants to merge 3 commits into
zhengruifeng wants to merge 3 commits into
Conversation
uros-b
approved these changes
Aug 6, 2026
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