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

python_tutorial_lesson_10_aot_compilation_run incompatible with Numpy 2 #8380

Closed
alexreinking opened this issue Aug 9, 2024 · 0 comments · Fixed by #8381
Closed

python_tutorial_lesson_10_aot_compilation_run incompatible with Numpy 2 #8380

alexreinking opened this issue Aug 9, 2024 · 0 comments · Fixed by #8381

Comments

@alexreinking
Copy link
Member

alexreinking commented Aug 9, 2024

Numpy no longer automatically truncates Python integers to the destination type. So the following code causes an overflow error now:

    input = np.empty((640, 480), dtype=np.uint8, order='F')
    for y in range(480):
        for x in range(640):
            input[x, y] = x ^ (y + 1)

We can recover the old behavior by manually masking.

    input = np.empty((640, 480), dtype=np.uint8, order='F')
    for y in range(480):
        for x in range(640):
            input[x, y] = (x ^ (y + 1)) & 0xFF
alexreinking added a commit that referenced this issue Aug 9, 2024
Numpy 2.0 no longer performs narrowing conversions
automatically. We manually mask here instead.

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

Successfully merging a pull request may close this issue.

1 participant