-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Parametrize PeriodIndex tests #19659
Conversation
Codecov Report
@@ Coverage Diff @@
## master #19659 +/- ##
==========================================
- Coverage 91.58% 91.58% -0.01%
==========================================
Files 150 150
Lines 48806 48862 +56
==========================================
+ Hits 44701 44748 +47
- Misses 4105 4114 +9
Continue to review full report at Codecov.
|
with tm.assert_raises_regex(period.IncompatibleFrequency, msg): | ||
rng += other | ||
|
||
@pytest.mark.parametrize('other', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I'l like to see you not repeat the parameterization on every test. you can do this in a number of ways
- a fixture
- make a list of the parameters (then its easy to add on a particular test)
pd.offsets.MonthBegin(1), | ||
pd.offsets.Minute()] | ||
|
||
not_hourly_offsets = [timedelta(minutes=30), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from here down should be fixtures, then you don't need the parameterize on each function, just pass the argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just pushed with this change.
tm.assert_numpy_array_equal(idx.astype(object).values, exp) | ||
tm.assert_numpy_array_equal(idx._mpl_repr(), exp) | ||
|
||
# TODO: de-duplicate this version (from test_ops) with the one above |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when deduping (can be next pass). see if anyting can be parameterized
Multiple Travis builds have been running for almost 2hours. Is this the only PR affected? |
@pytest.fixture(params=[timedelta(minutes=30), | ||
np.timedelta64(30, 's'), | ||
Timedelta(seconds=30)] + _common_mismatch) | ||
def not_hourly(request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could I bother you for docstrings on these? They're printed out when running pytest --fixtures
, which I find really helpful in understanding what fixtures we already provide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed a commit with these added. Let me know if they need to be fleshed out etc.
If you find the motivation, I've got a handful of small PRs that need a nudge to get over the line (i.e. haven't gotten the "ping on green", but plausibly could): #19582, #19650, #19692, #19365, #19611, #19661. Less trivial but important from a blocker-for-bugfixes standpoint is #19672.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woa didn't realize fixtures prints these out. let' fix these next for all ones that don't have them. il'll create an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small changes. mainly interested in the de-classing in astype. other things can also be next pass. ping on green.
from pandas import NaT, Period, PeriodIndex, Int64Index, Index, period_range | ||
|
||
|
||
class TestPeriodIndexAsType(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove the class. normally don't use a class unless you have 2 (and then I would question why we are not doing in sub-modules), unless very short
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree on the why-is-a-class-needed bit. I'd also like to keep symmetry with the test_astype modules in tests.indexes.datetimes and tests.indexes.timedeltas. In an upcoming pass I'll de-class all three at the same time.
@pytest.fixture(params=[timedelta(minutes=30), | ||
np.timedelta64(30, 's'), | ||
Timedelta(seconds=30)] + _common_mismatch) | ||
def not_hourly(request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woa didn't realize fixtures prints these out. let' fix these next for all ones that don't have them. il'll create an issue
@pytest.fixture(params=[timedelta(minutes=30), | ||
np.timedelta64(30, 's'), | ||
Timedelta(seconds=30)] + _common_mismatch) | ||
def not_hourly(request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -305,16 +300,24 @@ def test_pi_add_int(self, one): | |||
rng += one | |||
tm.assert_index_equal(rng, expected) | |||
|
|||
def test_pi_sub_isub_int(self, one): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prob want to doc-string one (maybe rename to slightly more informative)
ping |
Thanks! |
* fixup formatting * parametrize PeriodIndex tests * fixup typo * put lists of params at module level * make fixtures * docstrings for fixtures * requested docstring
git diff upstream/master -u -- "*.py" | flake8 --diff