test_cumulative.py 647 B

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