zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pytest
 
import pandas._testing as tm
from pandas.core.arrays import TimedeltaArray
 
 
class TestAccumulator:
    def test_accumulators_disallowed(self):
        # GH#50297
        arr = TimedeltaArray._from_sequence_not_strict(["1D", "2D"])
        with pytest.raises(TypeError, match="cumprod not supported"):
            arr._accumulate("cumprod")
 
    def test_cumsum(self):
        # GH#50297
        arr = TimedeltaArray._from_sequence_not_strict(["1D", "2D"])
        result = arr._accumulate("cumsum")
        expected = TimedeltaArray._from_sequence_not_strict(["1D", "3D"])
        tm.assert_timedelta_array_equal(result, expected)