Skip to content

Support NamedTuple of different ordering #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2025

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!

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