Fix: shift_slice to accept single slices as argument, and return tuples
Two fixes to pystencils.slicing.shift_slice
:
- Previously,
shift_slice
assumed its argumentslices
to be iterable. Thus, it did not accept single slices as arguments. There are use cases, though, where it is necessary to shift a plainslice
object, or evenint
orfloat
objects which can also be seen as slices. An additionalisinstance
check takes care of this. - Previously,
shift_slice
returnedlist
s of slices. By default, Python wraps multidimensional slices astuple
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.