Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-36240: [Python] Refactor CumulativeSumOptions to a separate class for independent deprecation #36977

Merged
merged 21 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion python/pyarrow/_compute.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,34 @@ class PartitionNthOptions(_PartitionNthOptions):
self._set_options(pivot, null_placement)


cdef class _CumulativeSumOptions(FunctionOptions):
R-JunmingChen marked this conversation as resolved.
Show resolved Hide resolved
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):
R-JunmingChen marked this conversation as resolved.
Show resolved Hide resolved
self._set_options(start, skip_nulls)

R-JunmingChen marked this conversation as resolved.
Show resolved Hide resolved

cdef class _CumulativeOptions(FunctionOptions):
def _set_options(self, start, skip_nulls):
if start is None:
Expand All @@ -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)
R-JunmingChen marked this conversation as resolved.
Show resolved Hide resolved


class CumulativeOptions(_CumulativeOptions):
Expand Down
2 changes: 1 addition & 1 deletion python/pyarrow/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
CastOptions,
CountOptions,
CumulativeOptions,
CumulativeOptions as CumulativeSumOptions,
CumulativeSumOptions,
DayOfWeekOptions,
DictionaryEncodeOptions,
RunEndEncodeOptions,
Expand Down