You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/03/18 12:59:07 UTC

[GitHub] [arrow] lidavidm commented on a change in pull request #12660: ARROW-15965: [Python] Add Scalar constructor of RoundToMultipleOptions to Python

lidavidm commented on a change in pull request #12660:
URL: https://github.com/apache/arrow/pull/12660#discussion_r829975339



##########
File path: python/pyarrow/_compute.pyx
##########
@@ -898,10 +898,16 @@ class RoundTemporalOptions(_RoundTemporalOptions):
 
 cdef class _RoundToMultipleOptions(FunctionOptions):
     def _set_options(self, multiple, round_mode):
-        self.wrapped.reset(
-            new CRoundToMultipleOptions(multiple,
-                                        unwrap_round_mode(round_mode))
-        )
+        if isinstance(multiple, Scalar):
+            self.wrapped.reset(
+                new CRoundToMultipleOptions(pyarrow_unwrap_scalar(multiple),
+                                            unwrap_round_mode(round_mode))
+            )
+        else:
+            self.wrapped.reset(
+                new CRoundToMultipleOptions((<double> multiple),

Review comment:
       Hmm, do we need to do more type checking here? What happens if `multiple` is neither scalar nor double?

##########
File path: python/pyarrow/_compute.pyx
##########
@@ -898,10 +898,16 @@ class RoundTemporalOptions(_RoundTemporalOptions):
 
 cdef class _RoundToMultipleOptions(FunctionOptions):
     def _set_options(self, multiple, round_mode):
-        self.wrapped.reset(
-            new CRoundToMultipleOptions(multiple,
-                                        unwrap_round_mode(round_mode))
-        )
+        if isinstance(multiple, Scalar):
+            self.wrapped.reset(
+                new CRoundToMultipleOptions(pyarrow_unwrap_scalar(multiple),
+                                            unwrap_round_mode(round_mode))
+            )
+        else:
+            self.wrapped.reset(
+                new CRoundToMultipleOptions((<double> multiple),

Review comment:
       Should we add a unit test too?




-- 
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: github-unsubscribe@arrow.apache.org

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