-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
parametrize the first few arithmetic tests #18133
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
Conversation
Hello @jbrockmendel! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on November 09, 2017 at 17:25 Hours UTC |
idx = DatetimeIndex(['2011-01-01', '2011-01-02']) | ||
msg = "cannot add DatetimeIndex and Timestamp" | ||
with tm.assert_raises_regex(TypeError, msg): | ||
idx + Timestamp('2011-01-01') | ||
|
||
def test_dti_radd_timestamp_raises(self): |
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.
we usually call these errors
tm.assert_index_equal(result, expected) | ||
rng += 1 | ||
tm.assert_index_equal(rng, expected) | ||
# Several ways of representing two hours |
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.
you should make this a fixture
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 getting comfortable with pytest.parametrize, will look into fixtures. Mind saving for a follow-up? I want to avoid making the mistake of having multiple active PRs touching the same modules lest rebase-hell ensue. Things Learned The Hard Way, Volume 8.
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.
well this ends up add and then removing lots of code
would just like to see it down once
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.
Fair enough.
|
||
@pytest.mark.parametrize('delta', two_hour_variants) | ||
@pytest.mark.parametrize('tz', tz) | ||
def test_dti_add_timedeltalike(self, tz, delta): |
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.
then you just add two_hour_variants as an argument (it will work the same way but actually slightly shorter). you ca also make tz a fixture and then the signatures are really simple, e.g. (assume both are fixtures)
def test_dti_add_timedeltalike(self, tz, two_hour_variants):
....
with test the product of tz x two_hour_variants
Codecov Report
@@ Coverage Diff @@
## master #18133 +/- ##
==========================================
- Coverage 91.28% 91.26% -0.02%
==========================================
Files 163 163
Lines 50122 50127 +5
==========================================
- Hits 45752 45749 -3
- Misses 4370 4378 +8
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18133 +/- ##
==========================================
- Coverage 91.42% 91.4% -0.02%
==========================================
Files 163 163
Lines 50064 50064
==========================================
- Hits 45772 45763 -9
- Misses 4292 4301 +9
Continue to review full report at Codecov.
|
After spending a little time with the docs/examples, I think pytest.fixture is going to stay outside my comfort zone for a while. |
look at pandas/tests/reshape/test_merge.py for an example (or pandas/tests/io/tests_parquet.py for more sophisticated usage) |
The fixtures there look like they each provide a single DataFrame. We need separate tests for each timezone. Something like:
would pass the whole |
“”” |
Too much magic for me, can't implement that with a clear conscience. We've got a good clean win here using pytest.parametrize in more places than before. |
fixed up. pls always rebase when you push on anything. |
Travis error is looks like a DNS fail. Kind of refreshing to not be a Clipboard thing. |
i think all mac builds are borked atm |
Yikes. Just holler if I can do something useful; otherwise I'll stay out of the way. |
thanks @jbrockmendel |
Start parametrizing arithmetic tests for DatetimeIndex and TimedeltaIndex, with an eye towards re-usability.
Labelling tests with the types of operands and the operations, e.g. "test_dti_add_int" for DatetimeIndex + integer. This make it really easy to tell which combinations are and aren't implemented.