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

Convert to int to not break datashader CI for numpy 2 #141

Merged
merged 1 commit into from
Jun 28, 2024
Merged

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Jun 28, 2024

Basic this is failing on datashader, note it only fails when numba is disabled.

import os 
os.environ['NUMBA_DISABLE_JIT'] = '1' 

from numba import jit
import numpy as np

ngjit = jit(nopython=True, nogil=True)

bin_vec = np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
      dtype=np.uint8)
@ngjit
def _binary_2_int(bin_vec):
    """Convert a binary byte array to an integer"""
    res = 0
    next_val = 1
    width = len(bin_vec)
    for i in range(width):
        res += next_val*bin_vec[width - i - 1]
        next_val <<= 1
    return res

_binary_2_int(bin_vec)
OverflowError                             Traceback (most recent call last)
Cell In[4], line 18
     15         next_val <<= 1
     16     return res
---> 18 _binary_2_int(bin_vec)

Cell In[4], line 13, in _binary_2_int(bin_vec)
     10 width = len(bin_vec)
     11 for i in range(width):
     12     # res += next_val*int(bin_vec[width - i - 1])
---> 13     res += next_val*bin_vec[width - i - 1]
     15     next_val <<= 1
     16 return res

OverflowError: Python integer 256 out of bounds for uint8

@hoxbro hoxbro merged commit a462550 into main Jun 28, 2024
0 of 9 checks passed
@hoxbro hoxbro deleted the numpy2 branch June 28, 2024 14:51
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 this pull request may close these issues.

None yet

2 participants