Skip to content
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

cumprod method doesn't upcast unsigned integer array #9592

Open
2 tasks done
peterzsohar opened this issue May 27, 2024 · 0 comments · May be fixed by #9594
Open
2 tasks done

cumprod method doesn't upcast unsigned integer array #9592

peterzsohar opened this issue May 27, 2024 · 0 comments · May be fixed by #9594
Labels
bug - numerically incorrect Bugs: numerical behaviour is incorrect numpy

Comments

@peterzsohar
Copy link

peterzsohar commented May 27, 2024

Reporting a bug

Not only is it in conflict with numpy it also contradicts what numba does with signed integers.
Please see the example below:

import numpy as np
import numba

print("numpy version:", np.__version__)
# 1.26.4

print("numba version:", numba.__version__)
# 0.59.1

def do_cumprod():
    return np.array([20, 20], dtype=np.int8).cumprod(), np.array([20, 20], dtype=np.uint8).cumprod()

do_cumprod_jit = numba.njit(do_cumprod)

# numpy: upcasting
print("numpy:", do_cumprod())
# (array([ 20, 400]), array([ 20, 400], dtype=uint64))

# numba: upcasting for int8, no upcasting and overflow with uint8
print("numba:", do_cumprod_jit())
# (array([ 20, 400]), array([ 20, 144], dtype=uint8))

This behavior was first introduced with 0.57.

numpy version: 1.22.4
numba version: 0.56.4
numpy: (array([ 20, 400]), array([ 20, 400], dtype=uint64))
numba: (array([ 20, 400]), array([ 20, 400], dtype=uint64))
numpy version: 1.22.4
numba version: 0.57.0
numpy: (array([ 20, 400]), array([ 20, 400], dtype=uint64))
numba: (array([ 20, 400]), array([ 20, 144], dtype=uint8))

Thanks!

@sklam sklam added numpy bug - numerically incorrect Bugs: numerical behaviour is incorrect labels May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - numerically incorrect Bugs: numerical behaviour is incorrect numpy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants