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



##########
File path: python/pyarrow/_compute.pyx
##########
@@ -1052,37 +1055,31 @@ cdef class _DayOfWeekOptions(FunctionOptions):
 
 
 class DayOfWeekOptions(_DayOfWeekOptions):
-    def __init__(self, one_based_numbering=False, week_start=1):
+    def __init__(self, *, one_based_numbering=False, week_start=1):
         self._set_options(one_based_numbering, week_start)
 
 
 cdef class _AssumeTimezoneOptions(FunctionOptions):
+    _ambiguous_map = {
+        "raise": CAssumeTimezoneAmbiguous_AMBIGUOUS_RAISE,
+        "earliest": CAssumeTimezoneAmbiguous_AMBIGUOUS_EARLIEST,
+        "latest": CAssumeTimezoneAmbiguous_AMBIGUOUS_LATEST,
+    }
+    _nonexistent_map = {
+        "raise": CAssumeTimezoneNonexistent_NONEXISTENT_RAISE,
+        "earliest": CAssumeTimezoneNonexistent_NONEXISTENT_EARLIEST,
+        "latest": CAssumeTimezoneNonexistent_NONEXISTENT_LATEST,
+    }
+
     def _set_options(self, timezone, ambiguous, nonexistent):
-        ambiguous_dict = {
-            'raise': CAssumeTimezoneAmbiguous_AMBIGUOUS_RAISE,
-            'earliest': CAssumeTimezoneAmbiguous_AMBIGUOUS_EARLIEST,
-            'latest': CAssumeTimezoneAmbiguous_AMBIGUOUS_LATEST,
-        }
-        nonexistent_dict = {
-            'raise': CAssumeTimezoneNonexistent_NONEXISTENT_RAISE,
-            'earliest': CAssumeTimezoneNonexistent_NONEXISTENT_EARLIEST,
-            'latest': CAssumeTimezoneNonexistent_NONEXISTENT_LATEST,
-        }
-
-        if ambiguous not in ambiguous_dict:
-            raise ValueError(
-                "{!r} is not a valid 'ambiguous' keyword".format(ambiguous)
-            )
-        if nonexistent not in nonexistent_dict:
-            raise ValueError(
-                "{!r} is not a valid 'nonexistent' keyword".format(
-                    nonexistent)
-            )
+        if ambiguous not in self._ambiguous_map:
+            _raise_invalid_function_option(ambiguous, "ambiguous")
+        if nonexistent not in self._nonexistent_map:
+            _raise_invalid_function_option(nonexistent, "nonexistent")

Review comment:
       The "ambiguous" is not the about the timezone, but the timestamp. So 
something like `'ambiguous' timestamp handling` would be OK as well I think




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