Skip to content

nancumsum result for numba and numpy does not match #79

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

Closed
Illviljan opened this issue Jul 8, 2023 · 1 comment
Closed

nancumsum result for numba and numpy does not match #79

Illviljan opened this issue Jul 8, 2023 · 1 comment
Labels

Comments

@Illviljan
Copy link

Illviljan commented Jul 8, 2023

import numpy as np
import numpy_groupies as npg


s = npg.aggregate_numpy.aggregate(
    [0, 0, 0, 1, 1, 0, 0], [2, 2, np.nan, 2, 2, 2, 2], func="nancumsum"
)
ss = npg.aggregate_numba.aggregate(
    [0, 0, 0, 1, 1, 0, 0], [2, 2, np.nan, 2, 2, 2, 2], func="nancumsum"
)
np.testing.assert_allclose(s, ss)

AssertionError: 
Not equal to tolerance rtol=1e-07, atol=0

(shapes (6,), (7,) mismatch)
 x: array([2., 4., 2., 4., 6., 8.])
 y: array([2., 4., 4., 2., 4., 6., 8.])

npg.__version__
Out[5]: '0.9.22'

Doesn't look like the nancumsum function is being chosen.

def _nancumsum(group_idx, a, size, fill_value=None, dtype=None):
a_nonans = np.where(np.isnan(a), 0, a)
group_idx_nonans = np.where(
np.isnan(group_idx), np.nanmax(group_idx) + 1, group_idx
)
return _cumsum(group_idx_nonans, a_nonans, size, fill_value=fill_value, dtype=dtype)

@Illviljan Illviljan changed the title nancumsum implementation for numba and numpy does not match nancumsum result for numba and numpy does not match Jul 8, 2023
@ml31415 ml31415 added the bug label Oct 3, 2023
@ml31415 ml31415 closed this as completed in 162fdb9 Oct 3, 2023
@ml31415
Copy link
Owner

ml31415 commented Oct 3, 2023

Thanks for reporting this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants