From 6715b5b441bb9a9face8b3b4f751911d618b8b98 Mon Sep 17 00:00:00 2001
From: k-dominik <k-dominik@users.noreply.github.com>
Date: Wed, 25 Mar 2020 18:54:47 +0100
Subject: [PATCH] use tuples for numpy indexing
Bug: https://github.com/ukoethe/vigra/issues/528
Bug-Debian: https://bugs.debian.org/1026487
Origin: other, https://github.com/ukoethe/vigra/pull/475

`numpy` currently warns with the following warning when not using tuples for
indexing:

```
vigranumpy/vigra/arraytypes.py:1263: FutureWarning: Using a non-tuple sequence
for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`.
In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will
result either in an error or a different result.
```

fixed by simply converting the index to a tuple in relevant places.

fixes #474
---
 vigranumpy/lib/arraytypes.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/vigranumpy/lib/arraytypes.py
+++ b/vigranumpy/lib/arraytypes.py
@@ -1125,11 +1125,11 @@ class VigraArray(numpy.ndarray):
                 if self.axistags[k].isType(AxisType.UnknownAxisType):
                     raise RuntimeError("VigraArray.withAxes(): array must not contain axes of unknown type (key '?').")
                 if slicing[k] == 0 and self.shape[k] != 1:
                     raise RuntimeError("VigraArray.withAxes(): cannot drop non-singleton axis '%s'." % self.axistags[k].key)
             permutation = AxisTags(axisinfo).permutationFromNumpyOrder()
-            res = self[slicing].transposeToNumpyOrder().transpose(permutation)
+            res = self[tuple(slicing)].transposeToNumpyOrder().transpose(permutation)
         else:
             res = self.transposeToOrder(kw.get('order'))
             if kw.get('noChannels'):
                 res = res.dropChannelAxis()
         return res
@@ -1148,11 +1148,11 @@ class VigraArray(numpy.ndarray):
             try:
                 del stdTags[stdTags.index(tag.key)]
             except:
                 raise RuntimeError("VigraArray.view5D(): array contains unsuitable axis key '%s'." % tag.key)
         index = [Ellipsis] + [newaxis(eval('AxisInfo.' + k)) for k in stdTags]
-        return self[index].transposeToOrder(order)
+        return self[tuple(index)].transposeToOrder(order)
 
     def permutationToOrder(self, order):
         '''Create the permutation that would transpose this array into
            an array view with the given order (where order can be 'A',
            'C', 'F', 'V' with the usual meaning).
@@ -1271,11 +1271,11 @@ class VigraArray(numpy.ndarray):
             res = numpy.ndarray.__getitem__(self, index)
         except:
             if not isinstance(index, Iterable):
                 raise
             #create temporary index without AxisInfor in order to use np.ndarray.__getitem__
-            tmpindex = [None if isinstance(x, AxisInfo) else x for x in index]
+            tmpindex = tuple(None if isinstance(x, AxisInfo) else x for x in index)
             res = numpy.ndarray.__getitem__(self, tmpindex)
         if res is not self and hasattr(res, 'axistags'):
             if res.base is self or res.base is self.base:
                 res.axistags = res._transform_axistags(index)
             else:
