-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH-19629: Adding numpy nansun/nanmean, etc etc to _cython_table #19670
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
ENH-19629: Adding numpy nansun/nanmean, etc etc to _cython_table #19670
Conversation
Best is probably A whatsnew entry under bug fixes would be good, under the "Numeric" bug fixes section, saying that
|
Hello @AaronCritchley! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on April 25, 2018 at 11:23 Hours UTC |
Codecov Report
@@ Coverage Diff @@
## master #19670 +/- ##
==========================================
+ Coverage 91.77% 91.84% +0.06%
==========================================
Files 153 153
Lines 49257 49300 +43
==========================================
+ Hits 45207 45279 +72
+ Misses 4050 4021 -29
Continue to review full report at Codecov.
|
Hey @TomAugspurger - thanks so much for your help. Are the tests I've put in OK or would you rather me be more exhaustive? I considered adding in some tests with |
pandas/tests/test_nanops.py
Outdated
@@ -1004,6 +1004,95 @@ def prng(self): | |||
return np.random.RandomState(1234) | |||
|
|||
|
|||
class TestNumpyNaNFunctions(object): |
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 can be a single function that is parameterized over all of the methods
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, will do this soon - could you help with why the build is failing?
From looking at CircleCI it seems like it's not recognizing that np.nanprod is valid, do I need to remove the nanprod case for compat or something? Sorry if I'm being dense here.
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 might need to skip for older versions of numpy
not sure when certain ones were added
So in the parametrization you need to add a |
…19629-np-nan-funcs-to-cython-map
pandas/core/base.py
Outdated
} | ||
|
||
# np.nanprod was added in np version 1.10.0, we currently support >= 1.9 | ||
try: |
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.
If you have a preferred implementation for this, let me know and I'll happily change, explicitly checking version seemed ugly 😄
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 can just check _np_version_under1p10 and add it conditionally
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.
Awesome, didn't know this was a thing, thank you
@topper-123 thank you so much - I ended up changing the implementation rather than just xfailing the test, as the failure in the build was being hit in a non-test scenario, if you have better suggestions I'm happy to take them on! |
pandas/tests/test_nanops.py
Outdated
(np.cumsum, np.nancumsum) | ||
] | ||
|
||
def test_np_nan_functions(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.
parametrize these
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.
My bad, didn't realise you meant pytest.mark.parametrize
, implemented your suggestion now 😄
pandas/tests/test_nanops.py
Outdated
data.agg(nan_method), | ||
check_exact=True) | ||
|
||
@pytest.mark.parametrize("standard, nan_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.
u can parametrize over df and series (or make into fixtures)
then can inline the compare function
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'm not sure on a good way to handle the np compat tests if we took this approach, I'd be open to suggestions though
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.
@pytest.fixture(params=[Series(....), DataFrame()])
def obj(request):
return request.param
can you rebase |
@AaronCritchley are these failures related to your changes? https://travis-ci.org/pandas-dev/pandas/jobs/351535340#L2351 |
Hey @TomAugspurger, yep, I believe they are, I need to figure out the issue as everything passes locally. Open to suggestions if it's super obvious to you but happy to dive further if not. Seems like different behaviour in np.nanmax in that particular ci configuration. Also trying to get in the suggestions made by Jeff around using fixtures for the series / df once I've figured it out the above 😄 |
…19629-np-nan-funcs-to-cython-map
Refactored to make use of fixtures and rebased, still need to dig into the 3.5 build failure and figure out what's happening, help appreciated 😄 |
pandas/tests/test_nanops.py
Outdated
]) | ||
def test_np_nan_functions(standard, nan_method, nan_test_object): | ||
_compare_nan_method_output(nan_test_object, standard, nan_method) | ||
_compare_nan_method_output(nan_test_object, standard, nan_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.
Are these two lines identical?
I think it'd be clearly to just write out the tm.assert_almost_equal(nan_test_object.agg(standard), nan_test_object.agg(nan_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.
Yep, this was me being silly, fixed!
looks fine. ping on green. |
can you rebase |
can you rebase |
…19629-np-nan-funcs-to-cython-map
…onCritchley/pandas into ENH-19629-np-nan-funcs-to-cython-map
Hey @jreback, I've rebased, the CI pipeline is failing a single test on a single env - I'm looking into it but was having a hard time recreating the failed test. If it's anything obvious help would be much appreciated, I'll continue to dig and try to figure it out. EDIT: I can recreate the test now, which is good, but still haven't figured out the cause, will update if I find anything. |
Going to close this in case any other contributors are able to pick it up, if it doesn't get picked up I'll try to fix again at a later date 😄 |
git diff upstream/master -u -- "*.py" | flake8 --diff
As per the issue, here's proof of solution:
Where should I add tests for these changes? I wasn't sure on the best fit and how to most effectively test. Also, is a whatsnew entry needed here? If yes, any guidance on what it should be?