zhengruifeng opened a new pull request, #57749:
URL: https://github.com/apache/spark/pull/57749

   ### What changes were proposed in this pull request?
   
   This PR replaces the pandas UDF implementation of `np.heaviside` in pandas 
API on Spark with a native Spark `when` expression. It returns `0.0` for 
negative values, the second argument at either signed zero, and `1.0` for 
positive values; null and NaN first arguments propagate.
   
   The new test covers integral inputs, signed zero, NaN, infinities, and NaN 
as the second argument at zero.
   
   ### Why are the changes needed?
   
   Using native Spark expressions avoids pandas UDF and Arrow overhead while 
preserving NumPy `heaviside` semantics.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   - Added `NumPyCompatTests.test_np_heaviside`.
   - `ruff check python/pyspark/pandas/numpy_compat.py 
python/pyspark/pandas/tests/test_numpy_compat.py`
   - `ruff format --check python/pyspark/pandas/numpy_compat.py 
python/pyspark/pandas/tests/test_numpy_compat.py`
   - `python -m unittest 
pyspark.pandas.tests.test_numpy_compat.NumPyCompatTests.test_np_heaviside`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Codex GPT-5


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to