예제 #1
0
def test_to_offset_offset_input(offset):
    assert to_offset(offset) == offset


@pytest.mark.parametrize(('freq', 'expected'), [('M', MonthEnd()),
                                                ('2M', MonthEnd(n=2)),
                                                ('MS', MonthBegin()),
                                                ('2MS', MonthBegin(n=2)),
                                                ('D', Day()), ('2D', Day(n=2)),
                                                ('H', Hour()),
                                                ('2H', Hour(n=2)),
                                                ('T', Minute()),
                                                ('2T', Minute(n=2)),
                                                ('min', Minute()),
                                                ('2min', Minute(n=2)),
                                                ('S', Second()),
                                                ('2S', Second(n=2))],
                         ids=_id_func)
def test_to_offset_sub_annual(freq, expected):
    assert to_offset(freq) == expected


_ANNUAL_OFFSET_TYPES = {'A': YearEnd, 'AS': YearBegin}


@pytest.mark.parametrize(('month_int', 'month_label'),
                         list(_MONTH_ABBREVIATIONS.items()) + [('', '')])
@pytest.mark.parametrize('multiple', [None, 2])
@pytest.mark.parametrize('offset_str', ['AS', 'A'])
def test_to_offset_annual(month_label, month_int, multiple, offset_str):
    freq = offset_str
예제 #2
0
@pytest.mark.parametrize(
    ("freq", "expected"),
    [
        ("M", MonthEnd()),
        ("2M", MonthEnd(n=2)),
        ("MS", MonthBegin()),
        ("2MS", MonthBegin(n=2)),
        ("D", Day()),
        ("2D", Day(n=2)),
        ("H", Hour()),
        ("2H", Hour(n=2)),
        ("T", Minute()),
        ("2T", Minute(n=2)),
        ("min", Minute()),
        ("2min", Minute(n=2)),
        ("S", Second()),
        ("2S", Second(n=2)),
    ],
    ids=_id_func,
)
def test_to_offset_sub_annual(freq, expected):
    assert to_offset(freq) == expected


_ANNUAL_OFFSET_TYPES = {"A": YearEnd, "AS": YearBegin}


@pytest.mark.parametrize(("month_int", "month_label"),
                         list(_MONTH_ABBREVIATIONS.items()) + [(0, "")])
@pytest.mark.parametrize("multiple", [None, 2])
@pytest.mark.parametrize("offset_str", ["AS", "A"])
예제 #3
0
    return request.param


@pytest.mark.parametrize(
    ("offset", "expected_n"),
    [
        (BaseCFTimeOffset(), 1),
        (YearBegin(), 1),
        (YearEnd(), 1),
        (QuarterBegin(), 1),
        (QuarterEnd(), 1),
        (Tick(), 1),
        (Day(), 1),
        (Hour(), 1),
        (Minute(), 1),
        (Second(), 1),
        (Millisecond(), 1),
        (Microsecond(), 1),
        (BaseCFTimeOffset(n=2), 2),
        (YearBegin(n=2), 2),
        (YearEnd(n=2), 2),
        (QuarterBegin(n=2), 2),
        (QuarterEnd(n=2), 2),
        (Tick(n=2), 2),
        (Day(n=2), 2),
        (Hour(n=2), 2),
        (Minute(n=2), 2),
        (Second(n=2), 2),
        (Millisecond(n=2), 2),
        (Microsecond(n=2), 2),
    ],
예제 #4
0
def test_mul_float_multiple_next_higher_resolution():
    """Test more than one iteration through _next_higher_resolution is required."""
    assert 1e-6 * Second() == Microsecond()
    assert 1e-6 / 60 * Minute() == Microsecond()
예제 #5
0
@pytest.mark.parametrize(
    ('freq', 'expected'),
    [('M', MonthEnd()),
     ('2M', MonthEnd(n=2)),
     ('MS', MonthBegin()),
     ('2MS', MonthBegin(n=2)),
     ('D', Day()),
     ('2D', Day(n=2)),
     ('H', Hour()),
     ('2H', Hour(n=2)),
     ('T', Minute()),
     ('2T', Minute(n=2)),
     ('min', Minute()),
     ('2min', Minute(n=2)),
     ('S', Second()),
     ('2S', Second(n=2))],
    ids=_id_func
)
def test_to_offset_sub_annual(freq, expected):
    assert to_offset(freq) == expected


_ANNUAL_OFFSET_TYPES = {
    'A': YearEnd,
    'AS': YearBegin
}


@pytest.mark.parametrize(('month_int', 'month_label'),
                         list(_MONTH_ABBREVIATIONS.items()) + [(0, '')])