Skip to content

Commit

Permalink
Pull inserted axes through TransformCoords (#760)
Browse files Browse the repository at this point in the history
This patch adds a simplification to the TransformCoords operation that
removes inserted axes from its input coordinates and reapplies them to
the result. Besides improving the efficiency of the transformation
itself, this simplification also exposes insertion structure to any
operation following it such as PolyVal, which can then benefit from a
similar simplification.
  • Loading branch information
gertjanvanzwieten committed Dec 21, 2022
2 parents a564365 + 0ff26ed commit 49d1227
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nutils/evaluable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3898,6 +3898,10 @@ def _derivative(self, var, seen):
def _simplified(self):
if self._target == self._source:
return self._coords
cax = self.ndim - 1
coords, where = unalign(self._coords, naxes=cax)
if len(where) < cax:
return align(TransformCoords(self._target, self._source, self._index, coords), (*where, cax), self.shape)


class TransformIndex(Array):
Expand Down

0 comments on commit 49d1227

Please sign in to comment.