Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4df2bb7

Browse files
committed
Allow wraparound in image slice viewer example.
Also, drop the more expensive `np.clip` call.
1 parent e53876a commit 4df2bb7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/animation/image_slices_viewer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def __init__(self, ax, X):
2525
def onscroll(self, event):
2626
print("%s %s" % (event.button, event.step))
2727
if event.button == 'up':
28-
self.ind = np.clip(self.ind + 1, 0, self.slices - 1)
28+
self.ind = (self.ind + 1) % self.slices
2929
else:
30-
self.ind = np.clip(self.ind - 1, 0, self.slices - 1)
30+
self.ind = (self.ind - 1) % self.slices
3131
self.update()
3232

3333
def update(self):

0 commit comments

Comments
 (0)