zhengruifeng commented on code in PR #57783:
URL: https://github.com/apache/spark/pull/57783#discussion_r3719516908


##########
python/pyspark/pandas/numpy_compat.py:
##########
@@ -108,8 +108,8 @@
         lambda s1, s2: np.copysign(s1, s2), DoubleType()
     ),
     "float_power": lambda c1, c2: F.pow(c1.cast("double"), c2.cast("double")),
-    "floor_divide": pandas_udf(  # type: ignore[call-overload]
-        lambda s1, s2: np.floor_divide(s1, s2), DoubleType()
+    "floor_divide": lambda c1, c2: F.when(c2 == 0, F.lit(0.0)).otherwise(

Review Comment:
   Addressed in d163baaa422. The implementation now dispatches by input type: 
floating zero divisors return NaN for a zero dividend and signed infinity 
otherwise, while integral zero divisors retain zero. The focused test passes.



##########
python/pyspark/pandas/tests/test_numpy_compat.py:
##########
@@ -196,6 +196,19 @@ def test_np_ldexp(self):
 
         self.assert_eq(np.ldexp(psdf.x, psdf.exp), np.ldexp(pdf.x, pdf.exp), 
almost=True)
 
+    def test_np_floor_divide(self):

Review Comment:
   Addressed in d163baaa422. The test now includes a floating frame covering 
zero divisors, infinities, and NaN. The focused test passes.



-- 
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