-
-
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
Define boxplot inside DataFrameGroupBy definition #17179
Conversation
instead of pinning it on right after the definition; move the import of boxplot_frame_groupby to the top of the module. Start getting rid of the exec(foo) statements. In particular, the ones that define properties. Still need to figure out the ones defining methods.
I can't get CircleCI to load the error messages, so no idea why it's failing. |
@gfyoung Can you see what the problem is with CircleCI? |
@jbrockmendel : you can see for yourself in fact. Under the test summary, for each failing test, there's a "more" button to the right-hand side that you can click. |
As for why your tests are failing, they're failing because they aren't catching a |
It was stuck in spinning-umbrella mode last time I checked, but I'm getting the error messages now. Thanks. |
Codecov Report
@@ Coverage Diff @@
## master #17179 +/- ##
==========================================
- Coverage 91.02% 91% -0.03%
==========================================
Files 162 162
Lines 49517 49523 +6
==========================================
- Hits 45075 45068 -7
- Misses 4442 4455 +13
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17179 +/- ##
==========================================
- Coverage 91.02% 90.99% -0.04%
==========================================
Files 162 162
Lines 49517 49655 +138
==========================================
+ Hits 45075 45185 +110
- Misses 4442 4470 +28
Continue to review full report at Codecov.
|
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 fixing the general case should happen first (IOW actually generate the groupby whitelisted methods rather than using exec
). then this would be simpler and not as special casey.
That sounds great. I'll try to put that together this afternoon. |
Hello @jbrockmendel! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on August 12, 2017 at 01:18 Hours UTC |
Just pushed a commit that explicitly defines all of the inherited methods instead of generating them with closes #16959 Aside from using
A casual reader could easily look at In fact, Side-note: Most of the inherited methods allow for |
return f(other=other, method=method, min_periods=min_periods) | ||
|
||
@Appender(Series.fillna.__doc__) | ||
def fillna(self, value=None, method=None, axis=None, inplace=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.
many of these keywords need to be eliminated. e.g. axis
and inplace
, they don't make sense on groupby objects.
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.
As above, I suggest this should happen in a follow-up. This is not a new problem, but an existing problem that was hidden by exec
until 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.
there is not enough testing around this. i am concerned you are actually changing the signatures. can you add covereage for all of the exposed functions (just assert that they work with a full spread of arguments). xfail the ones that are problematic.
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 didn't address this point.
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're right. This point in my "get back to it later" pile, as it is several steps removed from the original goal of the PR.
_series_apply_whitelist): | ||
exec(_def_str) | ||
|
||
@Appender(Series.all.__doc__) |
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 adding the doc-string is not really enough. you need to have a bit of substitution and/or mention that this is actually a groupby method.
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.
Sure. Under the status-quo the docstring is attached verbatim but with some extra whitespace. My preference would be to address this in a follow-up 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.
that is fine
@@ -3964,13 +4012,117 @@ def filter(self, func, dropna=True, *args, **kwargs): # noqa | |||
|
|||
class DataFrameGroupBy(NDFrameGroupBy): | |||
_apply_whitelist = _dataframe_apply_whitelist |
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 concept of a whitelist may not be necessary anymore
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.
It is still referenced in _make_wrapper
and some of the tests. It might make sense to remove it at the same time as the __getattr__
change suggested above.
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 should not be referenced in the tests at all
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.
See tests/groupby/test_whitelist.py
Looks like it also shows up in _dir_additions
:
def _dir_additions(self):
return self.obj._dir_additions() | self._apply_whitelist
AFAICT _apply_whitelist
is a historical artifact that may not be needed anymore, but is not actively causing any problems at the moment.
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 would remove the whitelist entirely; since you are defining the whitelist the methods no longer are referenced thru that mechanism (and instead thru explicit methods). you can simply setup a list in the tests that is a list of these methods and check that they are defined.
return f(other=other, method=method, min_periods=min_periods) | ||
|
||
@Appender(Series.fillna.__doc__) | ||
def fillna(self, value=None, method=None, axis=None, inplace=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.
you didn't address this point.
@@ -3964,13 +4012,117 @@ def filter(self, func, dropna=True, *args, **kwargs): # noqa | |||
|
|||
class DataFrameGroupBy(NDFrameGroupBy): | |||
_apply_whitelist = _dataframe_apply_whitelist |
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 would remove the whitelist entirely; since you are defining the whitelist the methods no longer are referenced thru that mechanism (and instead thru explicit methods). you can simply setup a list in the tests that is a list of these methods and check that they are defined.
""" | ||
return the dtype object of the underlying data | ||
""" | ||
return self.__getattr__('dtype') |
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 indirection is extremely odd to do, simply use getattr(self.obj, 'dtype')
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.
Agreed. Again: this is the code that is generated by exec
in the status quo.
This PR has gotten stuck in the mud. I propose swiss-cheesing the problem into smaller pieces.
|
@jbrockmendel : Given how the conversation has gone, I think that sounds like a good idea. Keep this PR open until you're done dividing it up. |
instead of pinning it on right after the definition; move the import of
plotting._core.boxplot_frame_groupby
to the top of the module.Start getting rid of the
exec(...)
statements. In particular, the ones that defineproperties. Still need to figure out the ones defining methods.
git diff upstream/master -u -- "*.py" | flake8 --diff