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 parsing of BPM and CustomTransferMap from Elegant #273

Merged
merged 8 commits into from
Oct 10, 2024

Conversation

Hespe
Copy link
Member

@Hespe Hespe commented Oct 7, 2024

Description

The Elegant MONI element is currently not properly mapped to the Cheetah BPM. Furthermore, there is a slight issue with how MONI with non-zero length are handled.
Similarly the current parser for CustomTransferMap is faulty since the dtype of the resulting tensor cannot be properly inferred.

Motivation and Context

Types of changes

This PR is a breaking change, since elegant MONI elements are now mapped to BPM instead of Marker, requiring changes to downstream code.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Checklist

  • I have updated the changelog accordingly (required).
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have reformatted the code and checked that formatting passes (required).
  • I have have fixed all issues found by flake8 (required).
  • I have ensured that all pytest tests pass (required).
  • I have run pytest on a machine with a CUDA GPU and made sure all tests pass (required).
  • I have checked that the documentation builds (required).

Note: We are using a maximum length of 88 characters per line.

@Hespe Hespe self-assigned this Oct 7, 2024
@Hespe Hespe linked an issue Oct 7, 2024 that may be closed by this pull request
@Hespe Hespe marked this pull request as draft October 7, 2024 14:56
@Hespe Hespe changed the title Fix parsing of BPMs from elegant Fix parsing of BPM and CustomTransferMap from Elegant Oct 9, 2024
@Hespe Hespe linked an issue Oct 9, 2024 that may be closed by this pull request
@Hespe Hespe marked this pull request as ready for review October 9, 2024 14:25
@Hespe Hespe requested a review from jank324 October 9, 2024 14:25
Comment on lines +40 to +44
for i in range(2):
assert torch.isclose(converted.d1[i].length, correct_lattice.d1[i].length)
assert torch.isclose(converted.d2.length, correct_lattice.d2.length)
assert torch.isclose(converted.s1.length, correct_lattice.s1.length)
assert torch.isclose(converted.s1.e1, correct_lattice.s1.e1)
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this should be no loop and use torch.allclose.

Copy link
Member Author

@Hespe Hespe Oct 10, 2024

Choose a reason for hiding this comment

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

I am not sure how torch.allclose would work here, but maybe there is some trick I am missing. The problem is that we have two elements with name d1 and therefore two separate length tensors, not one multidimensional tensor.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see ... I misunderstood the that line 🙃

@jank324 jank324 merged commit ef0017e into desy-ml:master Oct 10, 2024
8 checks passed
@Hespe Hespe deleted the fix-elegant branch October 10, 2024 08:13
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.

Error in Elegant import Misleading BPM import in the Elegant converter
2 participants