edponce commented on a change in pull request #11147:
URL: https://github.com/apache/arrow/pull/11147#discussion_r708306876
##########
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:
Yes, it is missing. Thanks!
--
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]