Support NamedTuple of different ordering #120
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I came across the problem described in #100, and for my use case (users provide named tuples that are
inverse
-transformed with a pre-defined transform) it would be convenient to support different orderings of NamedTuples in TransformTuple{<:NamedTuple}. Of course, one can argue that a NamedTuple with a different order of names is not in the image of the transform (as everytransform
ed result is a NamedTuple of a different order), but I think in practice in most applicationsNamedTuple
s with differently ordered names are expected to behave in the same way and in the context of the transform one could justify this by operating with equivalence classes of named tuples with the same set of names.So in this PR I propose to allow for differently ordered NamedTuples in the NamedTuple transform. However, if the NamedTuple is a superset still an error is thrown. This felt consistent with the dimension/size checks for array transforms.