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 2021/10/19 18:07:36 UTC

[GitHub] [spark] xinrong-databricks commented on a change in pull request #34314: [SPARK-36231][PYTHON] Support arithmetic operations of decimal(nan) series

xinrong-databricks commented on a change in pull request #34314:
URL: https://github.com/apache/spark/pull/34314#discussion_r732122188



##########
File path: python/pyspark/pandas/tests/data_type_ops/test_num_ops.py
##########
@@ -344,40 +334,35 @@ def test_from_to_pandas(self):
             self.assert_eq(ps.from_pandas(pser), psser)
 
     def test_isnull(self):
-        pdf, psdf = self.numeric_w_nan_pdf, self.numeric_w_nan_psdf
-        for col in self.numeric_w_nan_df_cols:
+        pdf, psdf = self.pdf, self.psdf
+        for col in self.numeric_df_cols:
             self.assert_eq(pdf[col].isnull(), psdf[col].isnull())
 
     def test_astype(self):
         pdf, psdf = self.pdf, self.psdf
         for col in self.numeric_df_cols:
             pser, psser = pdf[col], psdf[col]
-            self.assert_eq(pser.astype(int), psser.astype(int))
+            if not pser.hasnans:
+                self.assert_eq(pser.astype(int), psser.astype(int))
+                self.assert_eq(pser.astype(np.int32), psser.astype(np.int32))
+                self.assert_eq(pser.astype(np.int16), psser.astype(np.int16))
+                self.assert_eq(pser.astype(np.int8), psser.astype(np.int8))
+                # TODO(SPARK-37039): the np.nan series.astype(bool) should be True
+                self.assert_eq(pser.astype(bool), psser.astype(bool))
+            else:
+                for int_type in [int, np.int32, np.int16, np.int8]:

Review comment:
       nit: shall we extract [int, np.int32, np.int16, np.int8] as a variable, and reuse it under `if not pser.hasnans:` as well?




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