Skip to content
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

Fix handling of event dimensions in ComposeTransform (fixes #1893). #1894

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

tillahoffmann
Copy link
Contributor

This PR fixes #1893, I think. It looks like the implicit end in the slice caused some trouble if there's only one transform.

@@ -282,7 +282,7 @@ def __eq__(self, other):

def _get_compose_transform_input_event_dim(parts):
input_event_dim = parts[-1].domain.event_dim
for part in parts[len(parts) - 1 :: -1]:
for part in parts[len(parts) - 1 : len(parts) : -1]:
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the catch! I think we need to ignore the -1 part here. Maybe using parts[:-1][::-1] to be less confusing?

Copy link
Member

Choose a reason for hiding this comment

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

It was surprised to me that

x = [10]
print(x[-2::-1])  # Output: [10] 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds great!

Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

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

Thanks, Till!

@fehiepsi fehiepsi merged commit b611610 into pyro-ppl:master Oct 23, 2024
4 checks passed
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.

Incorrect event dimension for ComposeTransform if transform reduces event dimensions
2 participants