jorisvandenbossche commented on a change in pull request #11147:
URL: https://github.com/apache/arrow/pull/11147#discussion_r707962252



##########
File path: python/pyarrow/_compute.pyx
##########
@@ -899,26 +900,26 @@ cdef class _TakeOptions(FunctionOptions):
 
 
 class TakeOptions(_TakeOptions):
-    def __init__(self, *, boundscheck=True):
+    def __init__(self, boundscheck=True):

Review comment:
       I would keep this (it's to force `boundscheck` to be a keyword argument, 
and never positional argument)
   
   (and the same for some cases below)

##########
File path: python/pyarrow/_compute.pyx
##########
@@ -690,99 +700,91 @@ class CastOptions(_CastOptions):
 
 
 cdef class _ElementWiseAggregateOptions(FunctionOptions):
-    def _set_options(self, bint skip_nulls):
+    def _set_options(self, skip_nulls):
         self.wrapped.reset(new CElementWiseAggregateOptions(skip_nulls))
 
 
 class ElementWiseAggregateOptions(_ElementWiseAggregateOptions):
-    def __init__(self, bint skip_nulls=True):
+    def __init__(self, skip_nulls=True):
         self._set_options(skip_nulls)
 
 
 cdef CRoundMode unwrap_round_mode(round_mode) except *:
-    if round_mode == 'down':
-        return CRoundMode_DOWN
-    elif round_mode == 'up':
-        return CRoundMode_UP
-    elif round_mode == 'towards_zero':
-        return CRoundMode_TOWARDS_ZERO
-    elif round_mode == 'towards_infinity':
-        return CRoundMode_TOWARDS_INFINITY
-    elif round_mode == 'half_down':
-        return CRoundMode_HALF_DOWN
-    elif round_mode == 'half_up':
-        return CRoundMode_HALF_UP
-    elif round_mode == 'half_towards_zero':
-        return CRoundMode_HALF_TOWARDS_ZERO
-    elif round_mode == 'half_towards_infinity':
-        return CRoundMode_HALF_TOWARDS_INFINITY
-    elif round_mode == 'half_to_even':
-        return CRoundMode_HALF_TO_EVEN
-    elif round_mode == 'half_to_odd':
-        return CRoundMode_HALF_TO_ODD
-    else:
-        raise ValueError('"{}" is not a valid round mode'.format(round_mode))
+    round_mode_dict = {
+        "down": CRoundMode_DOWN,
+        "up": CRoundMode_UP,
+        "towards_zero": CRoundMode_TOWARDS_ZERO,
+        "towards_infinity": CRoundMode_TOWARDS_INFINITY,
+        "half_down": CRoundMode_HALF_DOWN,
+        "half_up": CRoundMode_HALF_UP,
+        "half_towards_zero": CRoundMode_HALF_TOWARDS_ZERO,
+        "half_towards_infinity": CRoundMode_HALF_TOWARDS_INFINITY,
+        "half_to_even": CRoundMode_HALF_TO_EVEN,
+        "half_to_odd": CRoundMode_HALF_TO_ODD,
+    }
+
+    if round_mode not in round_mode_dict:
+        raise ValueError(f'"{round_mode}" is not a valid round mode')
 

Review comment:
       Is there missing a return value here?

##########
File path: python/pyarrow/_compute.pyx
##########
@@ -844,53 +846,52 @@ class ExtractRegexOptions(_ExtractRegexOptions):
 
 
 cdef class _SliceOptions(FunctionOptions):
-    def _set_options(self, int64_t start, int64_t stop, int64_t step):
+    def _set_options(self, start, stop, step):

Review comment:
       Is there a reason to remove them both here and in the init just below?

##########
File path: python/pyarrow/_compute.pyx
##########
@@ -844,53 +846,52 @@ class ExtractRegexOptions(_ExtractRegexOptions):
 
 
 cdef class _SliceOptions(FunctionOptions):
-    def _set_options(self, int64_t start, int64_t stop, int64_t step):
+    def _set_options(self, start, stop, step):
         self.wrapped.reset(new CSliceOptions(start, stop, step))
 
 
 class SliceOptions(_SliceOptions):
-    def __init__(self, int64_t start, int64_t stop=sys.maxsize,
-                 int64_t step=1):
+    def __init__(self, start, stop=sys.maxsize, step=1):
         self._set_options(start, stop, step)
 
 
 cdef class _FilterOptions(FunctionOptions):
-    def _set_options(self, null_selection_behavior):
-        if null_selection_behavior == 'drop':
-            self.wrapped.reset(
-                new CFilterOptions(CFilterNullSelectionBehavior_DROP))
-        elif null_selection_behavior == 'emit_null':
-            self.wrapped.reset(
-                new CFilterOptions(CFilterNullSelectionBehavior_EMIT_NULL))
-        else:
+    null_selection_dict = {
+        "drop": CFilterNullSelectionBehavior_DROP,
+        "emit_null": CFilterNullSelectionBehavior_EMIT_NULL,
+    }
+
+    def _set_options(self, null_selection):
+        if null_selection not in null_selection_dict:
             raise ValueError(
-                '"{}" is not a valid null_selection_behavior'
-                .format(null_selection_behavior))
+                f'"{null_selection}" is not a valid null_selection_behavior')
+        self.wrapped.reset(
+            new CFilterOptions(null_selection_dict[null_selection])
+        )
 
 
 class FilterOptions(_FilterOptions):
-    def __init__(self, null_selection_behavior='drop'):
-        self._set_options(null_selection_behavior)
+    def __init__(self, null_selection="drop"):

Review comment:
       This is changing the name of the keyword in the public function?




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


Reply via email to