Skip to content

Commit

Permalink
Apply as_tensor after index sums
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Jan 26, 2025
1 parent 83609f8 commit 36e0e5d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions ufl/exproperators.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,20 +406,17 @@ def _getitem(self, component):
mi = MultiIndex(all_indices)
a = Indexed(self, mi)

# TODO: I think applying as_tensor after index sums results in
# cleaner expression graphs.

# If the Ellipsis or any slices were found, wrap as tensor valued
# with the slice indices created at the top here
if slice_indices:
a = as_tensor(a, slice_indices)

# If any repeated indices were found, apply implicit summation
# over those
for i in repeated_indices:
mi = MultiIndex((i,))
a = IndexSum(a, mi)

# If the Ellipsis or any slices were found, wrap as tensor valued
# with the slice indices created at the top here
if slice_indices:
a = as_tensor(a, slice_indices)

# Check for zero (last so we can get indices etc from a, could
# possibly be done faster by checking early instead)
if isinstance(self, Zero):
Expand Down

0 comments on commit 36e0e5d

Please sign in to comment.