Yikun commented on a change in pull request #32821:
URL: https://github.com/apache/spark/pull/32821#discussion_r649663634



##########
File path: python/pyspark/pandas/tests/data_type_ops/test_decimal_ops.py
##########
@@ -0,0 +1,65 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import decimal as d
+
+import numpy as np
+import pandas as pd
+
+from pyspark.pandas.data_type_ops.num_ops import DecimalOps
+from pyspark import pandas as ps
+from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
+from pyspark.testing.pandasutils import PandasOnSparkTestCase
+
+
+class DecimalOpsTest(PandasOnSparkTestCase, TestCasesUtils):
+    @property
+    def decimal_pser(self):
+        return pd.Series([d.Decimal(1.0), d.Decimal(2.0), d.Decimal(np.nan)])
+
+    @property
+    def decimal_psser(self):
+        return ps.from_pandas(self.decimal_pser)
+
+    @property
+    def float_pser(self):
+        return pd.Series([1, 2, np.nan], dtype=float)
+
+    @property
+    def float_psser(self):
+        return ps.from_pandas(self.float_pser)
+
+    def test_datatype_ops(self):
+        psser = self.decimal_psser
+        self.assertIsInstance(psser._dtype_op, DecimalOps)
+        self.assertEqual(psser._dtype_op.pretty_name, "decimal")
+
+    def test_isnull(self):

Review comment:
       Yep

##########
File path: python/pyspark/pandas/tests/data_type_ops/test_decimal_ops.py
##########
@@ -0,0 +1,65 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import decimal as d
+
+import numpy as np
+import pandas as pd
+
+from pyspark.pandas.data_type_ops.num_ops import DecimalOps
+from pyspark import pandas as ps
+from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
+from pyspark.testing.pandasutils import PandasOnSparkTestCase
+
+
+class DecimalOpsTest(PandasOnSparkTestCase, TestCasesUtils):
+    @property
+    def decimal_pser(self):
+        return pd.Series([d.Decimal(1.0), d.Decimal(2.0), d.Decimal(np.nan)])
+
+    @property
+    def decimal_psser(self):
+        return ps.from_pandas(self.decimal_pser)
+
+    @property
+    def float_pser(self):
+        return pd.Series([1, 2, np.nan], dtype=float)
+
+    @property
+    def float_psser(self):
+        return ps.from_pandas(self.float_pser)
+
+    def test_datatype_ops(self):
+        psser = self.decimal_psser
+        self.assertIsInstance(psser._dtype_op, DecimalOps)
+        self.assertEqual(psser._dtype_op.pretty_name, "decimal")
+
+    def test_isnull(self):
+        deci_psser = self.decimal_psser
+        float_psser = self.float_psser
+
+        self.assertEqual(deci_psser._dtype_op.pretty_name, "decimal")
+        self.assertEqual(float_psser._dtype_op.pretty_name, "fractions")
+
+        self.assert_eq(
+            pd.Series([False, False, False], index=[0, 1, 2]),
+            deci_psser._dtype_op.isnull(deci_psser),

Review comment:
       Good suggestion.

##########
File path: python/pyspark/pandas/data_type_ops/base.py
##########
@@ -206,3 +209,10 @@ def restore(self, col: pd.Series) -> pd.Series:
     def prepare(self, col: pd.Series) -> pd.Series:
         """Prepare column when from_pandas."""
         return col.replace({np.nan: None})
+
+    def isnull(self, element):

Review comment:
       Sure, it would be:
   `def isnull(self, series) -> Union["Series", "Index"]:`

##########
File path: python/pyspark/pandas/tests/data_type_ops/test_decimal_ops.py
##########
@@ -0,0 +1,65 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import decimal as d
+
+import numpy as np
+import pandas as pd
+
+from pyspark.pandas.data_type_ops.num_ops import DecimalOps
+from pyspark import pandas as ps
+from pyspark.pandas.tests.data_type_ops.testing_utils import TestCasesUtils
+from pyspark.testing.pandasutils import PandasOnSparkTestCase
+
+
+class DecimalOpsTest(PandasOnSparkTestCase, TestCasesUtils):
+    @property
+    def decimal_pser(self):
+        return pd.Series([d.Decimal(1.0), d.Decimal(2.0), d.Decimal(np.nan)])
+
+    @property
+    def decimal_psser(self):
+        return ps.from_pandas(self.decimal_pser)
+
+    @property
+    def float_pser(self):
+        return pd.Series([1, 2, np.nan], dtype=float)
+
+    @property
+    def float_psser(self):
+        return ps.from_pandas(self.float_pser)
+
+    def test_datatype_ops(self):
+        psser = self.decimal_psser
+        self.assertIsInstance(psser._dtype_op, DecimalOps)
+        self.assertEqual(psser._dtype_op.pretty_name, "decimal")
+
+    def test_isnull(self):
+        deci_psser = self.decimal_psser
+        float_psser = self.float_psser
+
+        self.assertEqual(deci_psser._dtype_op.pretty_name, "decimal")
+        self.assertEqual(float_psser._dtype_op.pretty_name, "fractions")
+
+        self.assert_eq(
+            pd.Series([False, False, False], index=[0, 1, 2]),
+            deci_psser._dtype_op.isnull(deci_psser),
+        )
+        self.assert_eq(
+            pd.Series([False, False, True], index=[0, 1, 2]),
+            float_psser._dtype_op.isnull(float_psser),

Review comment:
       It just because I didn't realize we can use pandas.isnull result 
directly. : ), will fix in next patch




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

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