Skip to content

Instantly share code, notes, and snippets.

@sofroniewn
Created March 4, 2020 23:40
Show Gist options
  • Save sofroniewn/29878fe66fbe9d61c264d56cdd5591d3 to your computer and use it in GitHub Desktop.
Save sofroniewn/29878fe66fbe9d61c264d56cdd5591d3 to your computer and use it in GitHub Desktop.
holder for TransformChain
class TransformChain(ListModel, Transform):
def __init__(self, transforms=[]):
super().__init__(
basetype=Transform,
iterable=transforms,
lookup={str: lambda q, e: q == e.name},
)
def __call__(self, coords):
return tz.pipe(coords, *self)
def __newlike__(self, iterable):
return ListModel(self._basetype, iterable, self._lookup)
def set_slice(self, axes: Sequence[int]) -> TransformChain:
return TransformChain([tf.set_slice(axes) for tf in self])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment