Skip to content

Commit 95836db

Browse files
committed
added check that we are not beyond our length in viewer.Product
1 parent 6601c0c commit 95836db

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

larray/viewer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ def __init__(self, arrays):
325325
self.length = np.prod(shape)
326326

327327
def to_tuple(self, key):
328+
if key >= self.length:
329+
raise IndexError("index %d out of range for Product of length %d" % (key, self.length))
328330
return tuple(key // div % mod for div, mod in self.div_mod)
329331

330332
def __len__(self):

0 commit comments

Comments
 (0)