Skip to content

[SPARK-58553][PS][FOLLOWUP] Preserve signed zero in NumPy fmax and fmin - #57819

Open
zhengruifeng wants to merge 3 commits into
apache:masterfrom
zhengruifeng:pandas-native-fmax-fmin-followup-dev2
Open

[SPARK-58553][PS][FOLLOWUP] Preserve signed zero in NumPy fmax and fmin#57819
zhengruifeng wants to merge 3 commits into
apache:masterfrom
zhengruifeng:pandas-native-fmax-fmin-followup-dev2

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

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

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