aboutsummaryrefslogtreecommitdiff
path: root/tests/incite/test_interval_idx.py
blob: 04d0bb2180deeff0634c33abe1215fb98464e2f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from datetime import UTC, datetime

import pandas as pd


class TestIntervalIndex:

    def test_init(self):
        start = datetime(year=2000, month=1, day=1, tzinfo=UTC)
        end = datetime(year=2000, month=1, day=10, tzinfo=UTC)

        iv_r: pd.IntervalIndex = pd.interval_range(
            start=start, end=end, freq="1d", closed="left"
        )
        assert isinstance(iv_r, pd.IntervalIndex)
        assert len(iv_r.to_list()) == 9

        # If the offset is longer than the end - start it will not
        #   error. It will simply have 0 rows.
        iv_r: pd.IntervalIndex = pd.interval_range(
            start=start, end=end, freq="30D", closed="left"
        )
        assert isinstance(iv_r, pd.IntervalIndex)
        assert len(iv_r.to_list()) == 0