-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Added regression test #31538
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
TST: Added regression test #31538
Conversation
Hello @MomIsBestFriend! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-04-03 09:15:17 UTC |
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 think a more logical home might be pandas/tests/arrays/test_datetimes.py but @jbrockmendel might have more insight
@MomIsBestFriend is moving this to tests.arithmetic something you're up for? (theres lots more that needs attention in that directory, so getting comfortable with the box_with_array pattern there would be worthwhile) |
@jbrockmendel I have to be honest here, I have tried to refactor the test case to use |
I appreciate that you gave it a shot despite the lacking documentation. The background: until relatively recently, we had separate arithmetic tests for Series/DataFrame/Index, and no systematic way of checking that these all behave the same (and in fact, they didnt). So we've been collecting arithmetic tests in tests.arithmetic and parametrizing over box_with_array (which is roughly just The general pattern is to start with a test for just, say, Series:
Parametrizing this over box_with_array would look like:
Does that help? Note: for exposition this example is implicitly assuming that |
Co-Authored-By: William Ayd <[email protected]>
c96a3ff
to
33e24a3
Compare
@@ -1056,6 +1056,22 @@ def test_dt64arr_add_sub_parr( | |||
) | |||
assert_invalid_addsub_type(dtarr, parr, msg) | |||
|
|||
def test_timestamp_and_time_dtype_raises(self, box_with_array): |
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.
"and" -> "addsub"
) | ||
|
||
with pytest.raises(TypeError, match=msg): | ||
obj1 - obj2 |
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.
the reversed operation obj2 - obj1 should also raise right? How about the addition ops?
Can you add a This is looking really good, thanks. |
lgtm. @jbrockmendel if any comments. |
@@ -1056,6 +1057,33 @@ def test_dt64arr_add_sub_parr( | |||
) | |||
assert_invalid_addsub_type(dtarr, parr, msg) | |||
|
|||
def test_timestamp_addsub_time_dtype_raises(self, box_with_array): |
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.
"time_dtype" -> "time_objects"?
"timestamp" -> "dt64arr"
@@ -1056,6 +1057,33 @@ def test_dt64arr_add_sub_parr( | |||
) | |||
assert_invalid_addsub_type(dtarr, parr, msg) | |||
|
|||
def test_timestamp_addsub_time_dtype_raises(self, box_with_array): |
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.
tz_naive_fixture
|
||
# add | ||
obj1 + obj2 | ||
obj2 + obj1 |
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.
should we be testing that all four of these ops raise TypeError?
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.
Yea this isn't very clear as is whether one or all of these raise a TypeError - can these be split into different contexts?
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.
Or alternately you can parametrize add, radd, sub, rsub
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.
Or alternately you can parametrize add, radd, sub, rsub
I can do that, is that's the preferred way?
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.
dealer's choice. i tend not to parametrize over add/radd/sub/rsub since it repeats all the setup code for for what i see as little gain, but on a case-by-case basis if it improves clarity, go for it.
|
||
# add | ||
obj1 + obj2 | ||
obj2 + obj1 |
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.
Yea this isn't very clear as is whether one or all of these raise a TypeError - can these be split into different contexts?
@@ -1069,6 +1071,60 @@ def test_dt64arr_add_sub_parr( | |||
) | |||
assert_invalid_addsub_type(dtarr, parr, msg) | |||
|
|||
def test_dt64arr_addsub_time_object_raises(self, box_with_array, tz_naive_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.
nitpick: time_object -> time_objects. otherwise i think this is ready
Looks like tests are failing on some paths that go through numexpr |
@MomIsBestFriend can you merge master and see if you can get this to passing |
LGTM |
thanks @MomIsBestFriend |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff