-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
CLN: Refactor pandas/tests/base - part3 #30147
CLN: Refactor pandas/tests/base - part3 #30147
Conversation
0d9a817
to
1685be9
Compare
1685be9
to
4d1750c
Compare
Thanks for your reviews! |
I addressed all your comments @WillAyd @jschendel. Please have another look |
@jreback Like mentioned in the issue description and in this comment: The utils and fixtures in this PR will be used in more places than just I see now that not using the utils and fixtures anywhere makes it impossible to understand their purpose. I will update the PR and remove the usage of |
this is likely true, however, I would rather move them locally pandas/tests/base, THEN in a follow on conform names & patterns between multiple places in the codebase. |
Makes sense. It makes the PRs more atomic |
…nywhere else for now
@jreback @WillAyd @jschendel
Please have another look at the PR |
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.
Looks good one comment
340b47f
to
69a0a0d
Compare
f = lambda x: isinstance(x, DatetimeIndex) | ||
self.check_ops_properties(DatetimeIndex._field_ops, f) | ||
self.check_ops_properties(DatetimeIndex._object_ops, f) | ||
self.check_ops_properties(DatetimeIndex._bool_ops, f) |
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.
Already tested in pandas/tests/series/test_datetime_values.py::test_dt_namespace_accessor
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.
Good catch. test_dt_namespace_accessor could use a good refactor if youre up to it (separate PR)
@@ -83,74 +75,29 @@ def setup_method(self, method): | |||
|
|||
self.objs = self.indexes + self.series + self.narrow_series | |||
|
|||
def check_ops_properties(self, props, filter=None, ignore_failures=False): |
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.
This method was only used in pandas/tests/indexes. I could remove all tests where it was used though as they were redundant (already tested in pandas/tests/series/test_datetime_values.py::test_dt_namespace_accessor
)
self.is_valid_objs = [o for o in self.objs if mask(o)] | ||
self.not_valid_objs = [o for o in self.objs if not mask(o)] | ||
|
||
def test_ops_properties(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.
Already tested in pandas/tests/series/test_datetime_values.py::test_dt_namespace_accessor
self.is_valid_objs = [o for o in self.objs if mask(o)] | ||
self.not_valid_objs = [] | ||
|
||
def test_ops_properties(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.
Already tested in pandas/tests/series/test_datetime_values.py::test_dt_namespace_accessor
@jreback Thanks to your comment about redundant tests I could reduce the scope of this PR quite a bit further. It's ready to review now. |
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.
ok looks pretty good. @jbrockmendel if you'd have a look
@@ -265,7 +265,7 @@ def _get_opstr(op): | |||
rtruediv: "/", | |||
operator.floordiv: "//", | |||
rfloordiv: "//", | |||
operator.mod: None, # TODO: Why None for mod but '%' for rmod? | |||
operator.mod: "%", |
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.
do we have tests where this makes a difference? maybe this lets us use numexpr and performance is affected?
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.
Yeah, I wasn't sure about this one. Thought I give it a try and see if any of the CI hooks is failing. The 2 failing ones in pandas-dev.pandas (Linux py37_locale)
look unrelated though. I'll rebase and try again.
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.
@jbrockmendel CI is green now, so all tests seem to be fine with this change.
@jreback do you have any concerns about it?
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.
looks ok, original issue is that this looks like a format string to python
…fferently in pandas/tests/base/test_ops.py
… case differently in pandas/tests/base/test_ops.py" This reverts commit 8bf1142.
Friendly reminder @jreback |
@@ -265,7 +265,7 @@ def _get_opstr(op): | |||
rtruediv: "/", | |||
operator.floordiv: "//", | |||
rfloordiv: "//", | |||
operator.mod: None, # TODO: Why None for mod but '%' for rmod? | |||
operator.mod: "%", |
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.
looks ok, original issue is that this looks like a format string to python
thanks @SaturnFromTitan yeah love these test refactor PRs; we have built up some monotliths...though many are being taken down / split now, so thanks. |
Part of #23877
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Starting to dissolve the
Ops
Mixin to drive fixturization ofpandas/tests/base/