ukoethe / vigra

a generic C++ library for image analysis
http://ukoethe.github.io/vigra/
Other
406 stars 191 forks source link

builderror with numpy >=1.22 [IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices] #528

Closed ametzler closed 9 months ago

ametzler commented 1 year ago

Hello,

Upgrading numpy in Debian from 1.21.5 to 1.23.5-2 triggered a build error https://bugs.debian.org/1026487

executing test file /dev/shm/VIGRA/libvigraimpex-1.11.1/obj.x86_64-linux-gnu/vigranumpy/test/test_arraytypes.py
.EEEEEEEEEEEEEEE.....EE.
[...]
ERROR: test_arraytypes.testImage1
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/dev/shm/VIGRA/libvigraimpex-1.11.1/obj.x86_64-linux-gnu/vigranumpy/vigra/arraytypes.py", line 1271, in __getitem__
    res = numpy.ndarray.__getitem__(self, index)
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/dev/shm/VIGRA/libvigraimpex-1.11.1/obj.x86_64-linux-gnu/vigranumpy/test/test_arraytypes.py", line 551, in testImage1
    checkArray(arraytypes.Image, 1, 2)
  File "/dev/shm/VIGRA/libvigraimpex-1.11.1/obj.x86_64-linux-gnu/vigranumpy/test/test_arraytypes.py", line 169, in checkArray
    assert_equal(img.view5D('F').axistags, axistags5)
  File "/dev/shm/VIGRA/libvigraimpex-1.11.1/obj.x86_64-linux-gnu/vigranumpy/vigra/arraytypes.py", line 1153, in view5D
    return self[index].transposeToOrder(order)
  File "/dev/shm/VIGRA/libvigraimpex-1.11.1/obj.x86_64-linux-gnu/vigranumpy/vigra/arraytypes.py", line 1277, in __getitem__
    res = numpy.ndarray.__getitem__(self, tmpindex)
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

cu Andreas

jayaddison commented 1 year ago

I think that cherry-picking/porting the changes from #475 might help for this -- the stricter validation of array index access seems to be the reason for the deprecation notices mentioned by that pull request.

ametzler commented 1 year ago

[jayaddison] wrote

I think that cherry-picking/porting the changes from #475 might help for this -- the stricter validation of array index access seems to be the reason for the deprecation notices mentioned by that pull request.

Yes, indeed 6715b5b441bb9a9face8b3b4f751911d618b8b98 plus

--- libvigraimpex-1.11.1+dfsg.orig/vigranumpy/test/test_arraytypes.py
+++ libvigraimpex-1.11.1+dfsg/vigranumpy/test/test_arraytypes.py
@@ -1531,7 +1531,7 @@ def testMethods():
     assert_equal(b.axistags, a.axistags)

 def testUfuncs():
-    from numpy import bool, int8, uint8, int16, uint16, int32, uint32, int64, uint64
+    from numpy import int8, uint8, int16, uint16, int32, uint32, int64, uint64

seems to work.

hmaarrfk commented 9 months ago

bool error was fixed in https://github.com/ukoethe/vigra/commit/a2cfbff6f4e117b1d903de53b381328cd4a6c587