Skip to content

CLN: update tslibs/tseries test locations/imports #34614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions pandas/tests/tseries/frequencies/test_freq_code.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from pandas._libs.tslibs import to_offset
from pandas._libs.tslibs import Resolution, offsets, to_offset
from pandas._libs.tslibs.frequencies import (
FreqGroup,
_attrname_to_abbrevs,
Expand All @@ -9,9 +9,6 @@
get_freq_group,
get_to_timestamp_base,
)
from pandas._libs.tslibs.resolution import Resolution as _reso

import pandas.tseries.offsets as offsets


@pytest.fixture(params=list(_period_code_map.items()))
Expand Down Expand Up @@ -103,19 +100,19 @@ def test_get_to_timestamp_base(freqstr, exp_freqstr):
],
)
def test_get_attrname_from_abbrev(freqstr, expected):
assert _reso.get_reso_from_freq(freqstr).attrname == expected
assert Resolution.get_reso_from_freq(freqstr).attrname == expected


@pytest.mark.parametrize("freq", ["A", "Q", "M"])
def test_get_freq_unsupported_(freq):
# Lowest-frequency resolution is for Day
with pytest.raises(KeyError, match=freq.lower()):
_reso.get_reso_from_freq(freq)
Resolution.get_reso_from_freq(freq)


@pytest.mark.parametrize("freq", ["D", "H", "T", "S", "L", "U", "N"])
def test_get_freq_roundtrip2(freq):
obj = _reso.get_reso_from_freq(freq)
obj = Resolution.get_reso_from_freq(freq)
result = _attrname_to_abbrevs[obj.attrname]
assert freq == result

Expand Down
26 changes: 26 additions & 0 deletions pandas/tests/tseries/frequencies/test_frequencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest

from pandas._libs.tslibs import offsets

from pandas.tseries.frequencies import is_subperiod, is_superperiod


@pytest.mark.parametrize(
"p1,p2,expected",
[
# Input validation.
(offsets.MonthEnd(), None, False),
(offsets.YearEnd(), None, False),
(None, offsets.YearEnd(), False),
(None, offsets.MonthEnd(), False),
(None, None, False),
(offsets.YearEnd(), offsets.MonthEnd(), True),
(offsets.Hour(), offsets.Minute(), True),
(offsets.Second(), offsets.Milli(), True),
(offsets.Milli(), offsets.Micro(), True),
(offsets.Micro(), offsets.Nano(), True),
],
)
def test_super_sub_symmetry(p1, p2, expected):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity what is the difference between this and the original module for this test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current location is in tests.tslibs, which is explicitly aimed at _libs.tslibs (where these functions resided until recently)

assert is_superperiod(p1, p2) is expected
assert is_subperiod(p2, p1) is expected
22 changes: 0 additions & 22 deletions pandas/tests/tslibs/test_libfrequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from pandas._libs.tslibs.parsing import get_rule_month

from pandas.tseries import offsets
from pandas.tseries.frequencies import is_subperiod, is_superperiod # TODO: move tests


@pytest.mark.parametrize(
Expand Down Expand Up @@ -56,27 +55,6 @@ def test_period_str_to_code(obj, expected):
assert _period_str_to_code(obj) == expected


@pytest.mark.parametrize(
"p1,p2,expected",
[
# Input validation.
(offsets.MonthEnd(), None, False),
(offsets.YearEnd(), None, False),
(None, offsets.YearEnd(), False),
(None, offsets.MonthEnd(), False),
(None, None, False),
(offsets.YearEnd(), offsets.MonthEnd(), True),
(offsets.Hour(), offsets.Minute(), True),
(offsets.Second(), offsets.Milli(), True),
(offsets.Milli(), offsets.Micro(), True),
(offsets.Micro(), offsets.Nano(), True),
],
)
def test_super_sub_symmetry(p1, p2, expected):
assert is_superperiod(p1, p2) is expected
assert is_subperiod(p2, p1) is expected


@pytest.mark.parametrize(
"freq,expected,aliases",
[
Expand Down