pyUSID icon indicating copy to clipboard operation
pyUSID copied to clipboard

Error with numpy 2

Open rolandmas opened this issue 11 months ago • 2 comments

Hi, your friendly Debian package maintainer here. As part of the transition to numpy2 in Debian, we've noticed that pyusid fails to run its testsuite due to a "RecursionError: maximum recursion depth exceeded" exception.

It appears that the __eq__() method of the Dimension class calls np.allclose(self, other). The problem is that np.allclose() does a few tests and falls back to testing whether x == y (see numpy/_core/numeric.py on line 2449), which in turns… calls the Dimension.__eq__() method, and so on until the overflow.

I'm looking for a way to fix that, but if someone better versed in the code beats me to it, it'll probably be even better :-)

rolandmas avatar Mar 07 '25 15:03 rolandmas

It may be necessary to check the dimension attributes one by one, and then the arrays separately, in order to fix this. I have also found some np.product() calls that were causing trouble, and have gone ahead and removed them. The changes have been pushed to a new branch, and it should be compatible now, but these tests will have to be reworked.

ramav87 avatar Mar 07 '25 21:03 ramav87

The tests now pass for me and the Debian package with your patch, so thanks a lot :-)

rolandmas avatar Mar 14 '25 14:03 rolandmas