An error occurred while fetching the assigned milestone of the selected merge_request.
Fix: shift_slice to accept single slices as argument, and return tuples
Files
2+ 5
− 2
@@ -89,9 +89,12 @@ def shift_slice(slices, offset):
Two fixes to pystencils.slicing.shift_slice
:
shift_slice
assumed its argument slices
to be iterable. Thus, it did not accept single slices as arguments. There are use cases, though, where it is necessary to shift a plain slice
object, or even int
or float
objects which can also be seen as slices. An additional isinstance
check takes care of this.shift_slice
returned list
s of slices. By default, Python wraps multidimensional slices as tuple
s. Code for manipulating multidimensional slices thus expects them to be given as tuples. Also, although it is currently possible to access numpy arrays with lists of slices instead of tuples, this action produces a deprecation warning. Thus, shift_slice
is changed to return tuples.An additional test case evaluating array accesses with shifted slices is also added.