Commit 05140339 authored by Lukas Platz's avatar Lukas Platz
Browse files

fix FutureWarning 'non-tuple sequence for multidim. indexing'

See relevant error message below:

$ python nifty-dev/demos/getting_started_1.py
[…]/python3.6/site-packages/nifty5/utilities.py:227: 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.
  np.add(tmp.real, tmp.imag, out=res[slice1])
[…]/python3.6/site-packages/nifty5/utilities.py:239: FutureWarning: Using a non-tuple sequence for […]
  np.subtract(tmp[slice2].real, tmp[slice2].imag, out=res[slice1])
[…]/python3.6/site-packages/nifty5/utilities.py:243: FutureWarning: Using a non-tuple sequence for […]
  _fill_upper_half(tmp[dim1], res[dim1], axes2)
parent bb5c7a43
......@@ -223,7 +223,7 @@ def hartley(a, axes=None):
axes = tuple(range(tmp.ndim))
lastaxis = axes[-1]
ntmplast = tmp.shape[lastaxis]
slice1 = [slice(None)]*lastaxis + [slice(0, ntmplast)]
slice1 = tuple([slice(None)]*lastaxis + [slice(0, ntmplast)])
np.add(tmp.real, tmp.imag, out=res[slice1])
def _fill_upper_half(tmp, res, axes):
......@@ -236,9 +236,11 @@ def hartley(a, axes=None):
for i in axes[:-1]:
slice1[i] = slice(1, None)
slice2[i] = slice(None, 0, -1)
slice1 = tuple(slice1)
slice2 = tuple(slice2)
np.subtract(tmp[slice2].real, tmp[slice2].imag, out=res[slice1])
for i, ax in enumerate(axes[:-1]):
dim1 = [slice(None)]*ax + [slice(0, 1)]
dim1 = tuple([slice(None)]*ax + [slice(0, 1)])
axes2 = axes[:i] + axes[i+1:]
_fill_upper_half(tmp[dim1], res[dim1], axes2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment