danepitkin commented on code in PR #36977:
URL: https://github.com/apache/arrow/pull/36977#discussion_r1281115512
##########
python/pyarrow/_compute.pyx:
##########
@@ -1947,7 +1975,7 @@ cdef class _CumulativeOptions(FunctionOptions):
pyarrow_unwrap_scalar(start), skip_nulls))
except Exception:
_raise_invalid_function_option(
- start, "`start` type for CumulativeSumOptions", TypeError)
+ start, "`start` type for CumulativeOptions", TypeError)
Review Comment:
Nice catch!
##########
python/pyarrow/_compute.pyx:
##########
@@ -1933,6 +1933,34 @@ class PartitionNthOptions(_PartitionNthOptions):
self._set_options(pivot, null_placement)
+cdef class _CumulativeSumOptions(FunctionOptions):
+ def _set_options(self, start, skip_nulls):
+ if not isinstance(start, Scalar):
+ try:
+ start = lib.scalar(start)
+ except Exception:
+ _raise_invalid_function_option(
+ start, "`start` type for CumulativeSumOptions", TypeError)
+
+ self.wrapped.reset(new
CCumulativeOptions(pyarrow_unwrap_scalar(start), skip_nulls))
+
+
+class CumulativeSumOptions(_CumulativeSumOptions):
+ """
+ Options for `cumulative_sum` function.
+
+ Parameters
+ ----------
+ start : Scalar, default 0.0
+ Starting value for sum computation
+ skip_nulls : bool, default False
+ When false, the first encountered null is propagated.
+ """
+
+ def __init__(self, start=0.0, *, skip_nulls=False):
+ self._set_options(start, skip_nulls)
+
Review Comment:
We can go ahead and add the deprecation warning with
https://github.com/apache/arrow/blob/f44e28fa03a64ae5b3d9352d21aee2cc84f9af6c/python/pyarrow/util.py#L109
##########
python/pyarrow/_compute.pyx:
##########
@@ -1933,6 +1933,34 @@ class PartitionNthOptions(_PartitionNthOptions):
self._set_options(pivot, null_placement)
+cdef class _CumulativeSumOptions(FunctionOptions):
+ def _set_options(self, start, skip_nulls):
+ if not isinstance(start, Scalar):
+ try:
+ start = lib.scalar(start)
+ except Exception:
+ _raise_invalid_function_option(
+ start, "`start` type for CumulativeSumOptions", TypeError)
+
+ self.wrapped.reset(new
CCumulativeOptions(pyarrow_unwrap_scalar(start), skip_nulls))
+
+
+class CumulativeSumOptions(_CumulativeSumOptions):
+ """
+ Options for `cumulative_sum` function.
+
+ Parameters
+ ----------
+ start : Scalar, default 0.0
+ Starting value for sum computation
+ skip_nulls : bool, default False
+ When false, the first encountered null is propagated.
+ """
+
+ def __init__(self, start=0.0, *, skip_nulls=False):
Review Comment:
We should keep the implementation identical to `CumulativeOptions`, which
uses `start=None`. Arrow v13 will release with the new `CumulativeOptions`, but
this PR will release in Arrow v14. So the `start=None` change will already be
made.
##########
python/pyarrow/_compute.pyx:
##########
@@ -1933,6 +1933,34 @@ class PartitionNthOptions(_PartitionNthOptions):
self._set_options(pivot, null_placement)
+cdef class _CumulativeSumOptions(FunctionOptions):
Review Comment:
Could we delete this cdef class and just inherit from `_CumulativeOptions`?
--
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]