Skip to content

REF/TST: Add more pytest idiom to resample/test_datetime_index.py #24414

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 24 commits into from
Dec 28, 2018

Conversation

simonjayhawkins
Copy link
Member

@simonjayhawkins simonjayhawkins commented Dec 24, 2018

@codecov
Copy link

codecov bot commented Dec 24, 2018

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24414      +/-   ##
==========================================
+ Coverage    92.3%    92.3%   +<.01%     
==========================================
  Files         163      163              
  Lines       51943    51943              
==========================================
+ Hits        47946    47947       +1     
+ Misses       3997     3996       -1
Flag Coverage Δ
#multiple 90.71% <ø> (ø) ⬆️
#single 42.99% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/util/testing.py 87.84% <0%> (+0.09%) ⬆️

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 fc7bc3f...525ec03. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 24, 2018

Codecov Report

Merging #24414 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24414      +/-   ##
==========================================
- Coverage    92.3%   92.29%   -0.02%     
==========================================
  Files         163      163              
  Lines       51987    51969      -18     
==========================================
- Hits        47989    47967      -22     
- Misses       3998     4002       +4
Flag Coverage Δ
#multiple 90.7% <ø> (-0.02%) ⬇️
#single 43.01% <ø> (+0.01%) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/period.py 92.75% <0%> (-0.33%) ⬇️
pandas/core/indexes/timedeltas.py 90.11% <0%> (-0.31%) ⬇️
pandas/tseries/offsets.py 96.69% <0%> (-0.26%) ⬇️
pandas/core/arrays/datetimelike.py 95.93% <0%> (-0.22%) ⬇️
pandas/core/indexes/datetimes.py 96.31% <0%> (-0.02%) ⬇️
pandas/core/indexes/datetimelike.py 97.7% <0%> (+0.11%) ⬆️

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 08c920e...55b3954. Read the comment docs.

@mroeschke mroeschke added Refactor Internal refactoring of code Testing pandas testing functions or related to the test suite labels Dec 24, 2018
@pep8speaks
Copy link

pep8speaks commented Dec 24, 2018

Hello @simonjayhawkins! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on December 28, 2018 at 08:45 Hours UTC


class TestDatetimeIndex(object):
Copy link
Contributor

Choose a reason for hiding this comment

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

do these actually to be class based at all?

Copy link
Contributor

Choose a reason for hiding this comment

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

same for TDI?

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.

looks good. some suggestions.



def test_asfreq_bug():
import datetime as dt
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 put the import at the top

funcs = ['add', 'mean', 'prod', 'ohlc', 'min', 'max', 'var']
for f in funcs:
g._cython_agg_general(f)
from pandas.compat import StringIO
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 put the import at the top

index=dti, dtype='float64')
r = df.groupby(b).agg(np.sum)
# check all cython functions work
funcs = ['add', 'mean', 'prod', 'min', 'max', 'var']
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 add to the list to parameterize (future PR is ok)

Copy link
Member

@gfyoung gfyoung Dec 28, 2018

Choose a reason for hiding this comment

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

I suspect this can be a fixture, as I see that list (or something similar to it) in several places.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah we have this as a fixture already, just need to incorporate

4, 9, 4, 2
]}, index=date_range('2014-11-08', freq='6s', periods=4))
assert_frame_equal(result, expected)
pytest.raises(Exception, ts.asfreq, 'B')
Copy link
Contributor

Choose a reason for hiding this comment

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

btw ok to change these to the new format (if you want; we eventually want to fix all of these), e.g.

with pytest.raises(Exception):
    ts.asfreq('B')

assert (resampled.loc['1/1/2000 6:00:00'] == exp).all()


def test_downsample_non_unique():
Copy link
Contributor

Choose a reason for hiding this comment

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

on these extra long files, ok to put in some section separators and move functions around

somthing like

# ----
# ohlc
# ----

these make sense when we remove the class based testing, not super necessary but nice to have.

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 address this

Copy link
Member Author

Choose a reason for hiding this comment

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

There's still lots to do for this module... only a handful of tests were split or parametrised in this PR. i would prefer to move functions and add section separators as a parallel activity with the splitting and parametrizing of the remaining tests. are you OK with that?

Copy link
Contributor

Choose a reason for hiding this comment

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

sure, let's do after this one

@@ -79,7 +79,8 @@ def f(df):
tm.assert_index_equal(result.index, df.index)


@pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
@pytest.mark.filterwarnings("ignore::FutureWarning")
# @pytest.mark.filterwarnings("ignore:\\nPanel:FutureWarning")
Copy link
Contributor

Choose a reason for hiding this comment

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

?

@jreback jreback added the Resample resample method label Dec 25, 2018
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.

couple of comments. ideally like to organize this and / or split to multiple files; there is a lot going on here


rng = date_range('1/1/2000', '12/31/2000')
ts = Series(np.random.randn(len(rng)), index=rng)
def test_resample_categorical_data_with_timedeltaindex():
Copy link
Contributor

Choose a reason for hiding this comment

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

move to tdi tests

@jreback jreback merged commit 5b61eaf into pandas-dev:master Dec 28, 2018
@jreback
Copy link
Contributor

jreback commented Dec 28, 2018

thanks!

@jreback jreback added this to the 0.24.0 milestone Dec 28, 2018
@simonjayhawkins simonjayhawkins deleted the resample-dti branch December 28, 2018 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Internal refactoring of code Resample resample method Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants