Commit 99b34c67 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

tweak slicing to be compatible with future numpy versions

parent 16bbe06f
......@@ -42,7 +42,7 @@ class CentralZeroPadder(LinearOperator):
if i in axes:
slicer_fw = slice(0, (self._domain.shape[i]+1)//2)
slicer_bw = slice(-1, -1-(self._domain.shape[i]//2), -1)
slicer.append([slicer_fw, slicer_bw])
slicer.append((slicer_fw, slicer_bw))
self.slicer = list(itertools.product(*slicer))
for i in range(len(self.slicer)):
......@@ -50,7 +50,8 @@ class CentralZeroPadder(LinearOperator):
if j not in axes:
tmp = list(self.slicer[i])
tmp.insert(j, slice(None))
self.slicer[i] = tmp
self.slicer[i] = tuple(tmp)
self.slicer = tuple(self.slicer)
@property
def domain(self):
......
......@@ -86,10 +86,10 @@ def get_slice_list(shape, axes):
[list(range(y)) for x, y in enumerate(shape) if x not in axes]
for index in product(*axes_iterables):
it_iter = iter(index)
slice_list = [
slice_list = tuple(
next(it_iter)
if axis else slice(None, None) for axis in axes_select
]
)
yield slice_list
else:
yield [slice(None, None)]
......@@ -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 = (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 = (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