Skip to content

Conversation

devmotion
Copy link
Collaborator

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 every transformed result is a NamedTuple of a different order), but I think in practice in most applications NamedTuples 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.

Copy link
Owner

@tpapp tpapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@tpapp tpapp merged commit d0c9261 into tpapp:master Jan 15, 2025
3 checks passed
@devmotion devmotion deleted the dw/namedtuple branch January 15, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants