You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/09/02 09:23:58 UTC

[GitHub] [spark] zero323 commented on a diff in pull request #37748: [SPARK-40210][PYTHON] Fix math atan2, hypot, pow and pmod float argument call

zero323 commented on code in PR #37748:
URL: https://github.com/apache/spark/pull/37748#discussion_r961479775


##########
python/pyspark/sql/tests/test_functions.py:
##########
@@ -1029,6 +1034,11 @@ def test_np_scalar_input(self):
             res = df.select(array_position(df.data, dtype(1)).alias("c")).collect()
             self.assertEqual([Row(c=1), Row(c=0)], res)
 
+    def test_binary_math_function(self):
+        for func, res in [(atan2, 0.13664), (hypot, 8.07527), (pow, 2.14359), (pmod, 1.1)]:
+            df = self.spark.range(1).select(round(func(1.1, 8), 5).alias("a"))
+            self.assertEqual(Row(a=res), df.first())

Review Comment:
   Nit. We could skip multiple actions here, doing something around these lines (not tested, there might be some typos there):
   
   
   ```python
   funcs, expected = zip(*[(atan2, 0.13664), (hypot, 8.07527), (pow, 2.14359), (pmod, 1.1)])
   df = spark.range(1).select(*(func(1.1, 8) for func in funcs)
   
   for a, e in zip(df.first(), expected):
       self.assertAlmostEqual(a, e, 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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org