Skip to content
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

Merged
merged 7 commits into from
Feb 17, 2018
Merged

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@codecov
Copy link

codecov bot commented Feb 13, 2018

Codecov Report

Merging #19659 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 89.95% <ø> (-0.01%) ⬇️
#single 41.75% <ø> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/io/s3.py 72.72% <0%> (-13.64%) ⬇️
pandas/io/packers.py 87.31% <0%> (-1.34%) ⬇️
pandas/core/arrays/base.py 60% <0%> (-0.61%) ⬇️
pandas/io/json/json.py 92.23% <0%> (-0.37%) ⬇️
pandas/io/common.py 68.77% <0%> (-0.3%) ⬇️
pandas/io/parquet.py 71.79% <0%> (-0.28%) ⬇️
pandas/io/parsers.py 95.32% <0%> (-0.25%) ⬇️
pandas/core/series.py 94.56% <0%> (-0.06%) ⬇️
pandas/core/frame.py 97.16% <0%> (-0.02%) ⬇️
pandas/core/indexes/multi.py 95.06% <0%> (-0.01%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 569bc7a...d93c11e. Read the comment docs.

with tm.assert_raises_regex(period.IncompatibleFrequency, msg):
rng += other

@pytest.mark.parametrize('other', [
Copy link
Contributor

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)

@jreback jreback added Testing pandas testing functions or related to the test suite Period Period data type labels Feb 14, 2018
pd.offsets.MonthBegin(1),
pd.offsets.Minute()]

not_hourly_offsets = [timedelta(minutes=30),
Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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

@jbrockmendel
Copy link
Member Author

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):
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@jreback jreback left a 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):
Copy link
Contributor

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

Copy link
Member Author

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):
Copy link
Contributor

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):
Copy link
Contributor

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):
Copy link
Contributor

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)

@jbrockmendel
Copy link
Member Author

ping

@TomAugspurger TomAugspurger merged commit c8d8331 into pandas-dev:master Feb 17, 2018
@TomAugspurger
Copy link
Contributor

Thanks!

@jbrockmendel jbrockmendel deleted the paramper branch February 17, 2018 21:11
@jreback jreback added this to the 0.23.0 milestone Feb 18, 2018
harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
* fixup formatting

* parametrize PeriodIndex tests

* fixup typo

* put lists of params at module level

* make fixtures

* docstrings for fixtures

* requested docstring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Period Period data type Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants