Commit 00651db2 authored by Gilles Guitton's avatar Gilles Guitton

- use of assert in Slices outsub_insub_slices() method.

parent 5bb48361
......@@ -602,15 +602,15 @@ class Slices(tuple):
return None, None
outmin = int(np.maximum(0, outmin))
outmax = int(np.minimum(abssize - 1, outmax))
# TMP check
if outmin < 0 or outmin >= abssize or outmax < 0 or outmax >= abssize:
raise Exception()
# Check outmin / outmax
assert outmin >= 0 and outmin < abssize and \
outmax >= 0 and outmax < abssize
# Find insub min and max
inmin = int(absmin + outmin * abs(absstep) - submin)
inmax = int(absmin + outmax * abs(absstep) - submin)
# TMP check
if inmin < 0 or inmin >= subsize or inmax < 0 or inmax >= subsize:
raise Exception()
# Check inmin / inmax
assert inmin >= 0 and inmin < subsize and \
inmax >= 0 and inmax < subsize
# Make slices
if absstep > 0:
outsub_slices.append(slice(outmin, outmax+1, 1))
......@@ -625,9 +625,7 @@ class Slices(tuple):
insub_slices.append(slice(inmax, instop, absstep))
res = (Slices(tuple(outsub_slices), shp),
Slices(tuple(insub_slices), sub_size))
# TMP check
for size1, size2 in zip(res[0].shape(), res[1].shape()):
if size1 != size2:
raise Exception()
# Check shapes
assert res[0].shape() == res[1].shape()
return res
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