Skip to content

Commit

Permalink
Catch users who try to index UFL expressions with negative indices (F…
Browse files Browse the repository at this point in the history
…EniCS#66)

Co-authored-by: Patrick Farrell <[email protected]>
  • Loading branch information
pefarrell and pefarrell authored Aug 13, 2021
1 parent 94badf8 commit a41f5b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ufl/indexed.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, expression, multiindex):
error("Invalid number of indices (%d) for tensor "
"expression of rank %d:\n\t%s\n"
% (len(multiindex), len(expression.ufl_shape), ufl_err_str(expression)))
if any(int(di) >= int(si)
if any(int(di) >= int(si) or int(di) < 0
for si, di in zip(shape, multiindex)
if isinstance(di, FixedIndex)):
error("Fixed index out of range!")
Expand Down

0 comments on commit a41f5b6

Please sign in to comment.