-
-
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
Changes from 5 commits
0d39286
47936c7
d2671e6
29ccb18
b702747
130f767
0e4657a
64c0d93
fdaeaf9
cabb307
0c5a2ae
7157161
93e332d
8c2a5dd
5326d56
bdd2917
528e12b
e88ac10
40e4dff
c9ddaff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1005,6 +1005,35 @@ def prng(self): | |
return np.random.RandomState(1234) | ||
|
||
|
||
class TestNumpyNaNFunctions(object): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
# xref GH 19629 | ||
methods_to_test = [ | ||
(np.sum, np.nansum), | ||
(np.mean, np.nanmean), | ||
(np.prod, np.nanprod), | ||
(np.std, np.nanstd), | ||
(np.var, np.nanvar), | ||
(np.median, np.nanmedian), | ||
(np.max, np.nanmax), | ||
(np.min, np.nanmin), | ||
(np.cumprod, np.nancumprod), | ||
(np.cumsum, np.nancumsum) | ||
] | ||
|
||
def test_np_nan_functions(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. My bad, didn't realise you meant |
||
test_series = pd.Series([1, 2, 3, 4, 5, 6]) | ||
test_df = pd.DataFrame([[1, 2, 3], [4, 5, 6]]) | ||
|
||
for standard, nan_method in self.methods_to_test: | ||
tm.assert_almost_equal(test_series.agg(standard), | ||
test_series.agg(nan_method), | ||
check_exact=True) | ||
tm.assert_almost_equal(test_df.agg(standard), | ||
test_df.agg(nan_method), | ||
check_exact=True) | ||
|
||
|
||
def test_use_bottleneck(): | ||
|
||
if nanops._BOTTLENECK_INSTALLED: | ||
|
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