diff --git a/python/pyarrow/_compute.pyx b/python/pyarrow/_compute.pyx index ac7efeff41aba..0842361908f0b 100644 --- a/python/pyarrow/_compute.pyx +++ b/python/pyarrow/_compute.pyx @@ -29,11 +29,12 @@ from pyarrow.lib cimport * from pyarrow.includes.common cimport * from pyarrow.includes.libarrow cimport * import pyarrow.lib as lib - +from pyarrow.util import _DEPR_MSG from libcpp cimport bool as c_bool import inspect import numpy as np +import warnings def _forbid_instantiation(klass, subclasses_instead=True): @@ -1947,7 +1948,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) class CumulativeOptions(_CumulativeOptions): @@ -1974,6 +1975,27 @@ class CumulativeOptions(_CumulativeOptions): self._set_options(start, skip_nulls) +class CumulativeSumOptions(_CumulativeOptions): + """ + Options for `cumulative_sum` function. + + Parameters + ---------- + start : Scalar, default None + Starting value for sum computation + skip_nulls : bool, default False + When false, the first encountered null is propagated. + """ + + def __init__(self, start=None, *, skip_nulls=False): + warnings.warn( + _DEPR_MSG.format("CumulativeSumOptions", "14.0", "CumulativeOptions"), + FutureWarning, + stacklevel=2 + ) + self._set_options(start, skip_nulls) + + cdef class _PairwiseOptions(FunctionOptions): def _set_options(self, period): self.wrapped.reset(new CPairwiseOptions(period)) diff --git a/python/pyarrow/compute.py b/python/pyarrow/compute.py index 0fefa18dd1136..1a3f753c688e7 100644 --- a/python/pyarrow/compute.py +++ b/python/pyarrow/compute.py @@ -34,7 +34,7 @@ CastOptions, CountOptions, CumulativeOptions, - CumulativeOptions as CumulativeSumOptions, + CumulativeSumOptions, DayOfWeekOptions, DictionaryEncodeOptions, RunEndEncodeOptions, diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index 98ab84c03900f..3c8e4ce8f8f2f 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -210,7 +210,12 @@ def test_option_class_equality(): buf = option.serialize() deserialized = pc.FunctionOptions.deserialize(buf) assert option == deserialized - assert repr(option) == repr(deserialized) + # TODO remove the check under the if statement + # when the deprecated class CumulativeSumOptions is removed. + if repr(option).startswith("CumulativeSumOptions"): + assert repr(deserialized).startswith("CumulativeOptions") + else: + assert repr(option) == repr(deserialized) for option1, option2 in zip(options, options[1:]): assert option1 != option2