harp-tech / harp-python

A low-level interface to data collected with the Harp binary protocol
https://harp-tech.org/articles/python.html
MIT License
4 stars 2 forks source link

Numpy 2.0 breaks `read` function #32

Closed bruno-f-cruz closed 4 days ago

bruno-f-cruz commented 4 months ago

Due to the way numpy scalar types are handled as of numpy 2.0 (https://numpy.org/neps/nep-0050-scalar-promotion.html), the following line:

https://github.com/harp-tech/harp-python/blob/c90387efdbb4d762073201b763025dd49d5d3117/harp/io.py#L84

throws the following error:

OverflowError: Python integer 1012842 out of bounds for uint8

This bug seems to be affecting the library in different places and we should test this before making any big changes. For now, lets clamp the numpy dependency to <2

jsiegle commented 2 months ago

Just encountered this as well -- explicitly casting stride and payloadtype to np.int32 fixes the problem for the read function.