Skip to content

Commit

Permalink
fix Transform.promote for non-scale transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
gertjanvanzwieten committed Feb 28, 2015
1 parent 1707510 commit 1dc98f5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions nutils/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,19 @@ def promote( self, ndims ):
if ndims == self.fromdims:
return self
index = core.index( trans.fromdims == self.fromdims for trans in self )
body = list( self[:index] )
uptrans = self[index]
assert uptrans.todims == self.fromdims+1
body = tuple( Scale( scale.linear, uptrans.apply(scale.offset) - scale.linear * uptrans.offset ) for scale in self[index+1:] )
# self[:index] << body << uptrans == self
assert equivalent( body+(uptrans,), self[index:] )
return TransformChain( TransformChain(self[:index]+body).promote(ndims)+(uptrans,) )
for i in range( index+1, len(self) ):
scale = self[i]
if not isinstance( scale, Scale ):
break
newscale = Scale( scale.linear, uptrans.apply(scale.offset) - scale.linear * uptrans.offset )
body.append( newscale )
else:
i = len(self)+1
assert equivalent( body[index:]+[uptrans], self[index:i] )
return TransformChain( TransformChain(body).promote(ndims)+(uptrans,)+self[i:] )


## TRANSFORM ITEMS
Expand Down

0 comments on commit 1dc98f5

Please sign in to comment.