hyb
2026-01-09 4cb426cb3ae31e772a09d4ade5b2f0242aaeefa0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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(["1D", "2D"], dtype="m8[ns]")
        with pytest.raises(TypeError, match="cumprod not supported"):
            arr._accumulate("cumprod")
 
    def test_cumsum(self, unit):
        # GH#50297
        dtype = f"m8[{unit}]"
        arr = TimedeltaArray._from_sequence(["1D", "2D"], dtype=dtype)
        result = arr._accumulate("cumsum")
        expected = TimedeltaArray._from_sequence(["1D", "3D"], dtype=dtype)
        tm.assert_timedelta_array_equal(result, expected)