Skip to content

Followup Cleanup DTI test_arithmetic, ASV #19149

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 12 commits into from
Jan 10, 2018

Conversation

jbrockmendel
Copy link
Member

Remove ASV for Timestamp.offset since that attribute has been removed.

tests.indexes.datetimes.test_arithmetic has a giant offsets test that this splits up into reasonably sized pieces.

  • one piece of that test currently only runs if klass is Series, but that sub-test is now valid for DatetimeIndex too, so this PR removes that condition.

  • parametrize tests that currently iterate over a dictionary of inputs.

  • A mistaken-looking indentation in that iteration ATM prevents a bunch of cases from running. This PR fixes that.

  • closes #xxxx

  • tests added / passed

  • passes git diff upstream/master -u -- "*.py" | flake8 --diff

  • whatsnew entry

do = do
kwargs = {}

for n in [0, 5]:
Copy link
Member Author

@jbrockmendel jbrockmendel Jan 9, 2018

Choose a reason for hiding this comment

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

I'm pretty sure that this for n in [0, 5]: down through line 563557 is intended to have one fewer level of indentation. That change is implemented up in test_dt64_with_DateOffsets.

Timestamp('2001-06-15')])

with warnings.catch_warnings(record=True):
for normalize in (True, False):
Copy link
Contributor

Choose a reason for hiding this comment

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

can parametrize on True/False as well

for normalize in (True, False):
if isinstance(cls_name, tuple):
cls_name, kwargs = cls_name
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't find this very pretty maybe

try:
    cls_name, kwargs = cls_name
except TypeError
    kwargs = {}

Copy link
Contributor

Choose a reason for hiding this comment

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

and add a comment

Copy link
Member Author

Choose a reason for hiding this comment

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

except TypeError

It actually raises a ValueError: too many values to unpack. The fact that this isn't obvious suggests we should keep the condition explicitly targeted.

The if/else can be moved outside the warnings.catch_warnings and de-indented, pretties it up a bit.

@jreback jreback added Testing pandas testing functions or related to the test suite Datetime Datetime data dtype Frequency DateOffsets labels Jan 9, 2018
@codecov
Copy link

codecov bot commented Jan 9, 2018

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19149      +/-   ##
==========================================
- Coverage   91.53%   91.51%   -0.03%     
==========================================
  Files         148      148              
  Lines       48783    48783              
==========================================
- Hits        44654    44643      -11     
- Misses       4129     4140      +11
Flag Coverage Δ
#multiple 89.88% <ø> (-0.03%) ⬇️
#single 41.61% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/plotting/_converter.py 65.22% <0%> (-1.74%) ⬇️
pandas/tseries/offsets.py 97.06% <0%> (+0.08%) ⬆️

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 9d8dbef...40a7c6a. Read the comment docs.

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.

comments, ping on green.

assert_func(result, exp)


@pytest.mark.parametrize('klass,assert_func', zip([Series, DatetimeIndex],
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't like the zip here, rather use a list of tuples


with warnings.catch_warnings(record=True):
for n in [0, 5]:
if (cls_name in ['WeekOfMonth', 'LastWeekOfMonth',
Copy link
Contributor

Choose a reason for hiding this comment

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

comment on why you are skipping the other cases

if (cls_name in ['WeekOfMonth', 'LastWeekOfMonth',
'FY5253Quarter', 'FY5253'] and n == 0):
continue
offset = getattr(pd.offsets, cls_name)(n,
Copy link
Contributor

Choose a reason for hiding this comment

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

format like

offset = getattr(pd.offsets, cls_name)
    n, normalize=normalize, **kwargs)

# the offset constructor
cls_name, kwargs = cls_name
else:
cls_name = cls_name
Copy link
Contributor

Choose a reason for hiding this comment

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

remove cls_name = cls_name

@@ -447,6 +447,110 @@ def test_dti_with_offset_series(self, tz, names):
tm.assert_series_equal(res3, expected_sub)


@pytest.mark.parametrize('klass,assert_func', zip([Series, DatetimeIndex],
Copy link
Contributor

Choose a reason for hiding this comment

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

don't use zip

@jreback jreback added this to the 0.23.0 milestone Jan 10, 2018
@jbrockmendel
Copy link
Member Author

Added commits removing a no-longer-needed "xfail", adding a missing "assert_series_equal", and breaking up/parametrizing some giant tests.

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 fine. I think next PR should be to split test_operators.py up into multiple files (in a sub-dir). merging after I fix the CI issues.

@jreback jreback merged commit 055bfa6 into pandas-dev:master Jan 10, 2018
@jreback
Copy link
Contributor

jreback commented Jan 10, 2018

thanks! pls do the split of test_operators.py next

maximveksler pushed a commit to maximveksler/pandas that referenced this pull request Jan 11, 2018
@jbrockmendel jbrockmendel deleted the followup branch January 23, 2018 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Frequency DateOffsets Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants