Open Hespe opened 1 month ago
Would be wise to merge this PR after #284 such that Beam.clone()
can be marked abstract.
Looks like the TransverseDeflectingCavity
is broken if its used within a Segment
and not on its own. The problem seems to be that Segment.track()
calls super.track()
, that is Element.track()
, if the Segment
is skippable. However, Element.track()
falls back to the transfer map, which is not implemented for the cavity.
The second test failure should be fixed once #288 is merged.
@jank324 There are some lines in the plotting tests that change context beyond their own scope:
Not sure if we should adjust that somehow or if its fine in this case.
Looks like the
TransverseDeflectingCavity
is broken if its used within aSegment
and not on its own. The problem seems to be thatSegment.track()
callssuper.track()
, that isElement.track()
, if theSegment
is skippable. However,Element.track()
falls back to the transfer map, which is not implemented for the cavity.
Raised this issue in #290
The plotting related failure is now fixed. This leaves only #290 as a blocker for this PR.
I think the generic clone()
implementation will not work for the CustomTransferMap
. The problem is that the important property is _transfer_map
but the constructor parameter does not have the underscore in front.
I think the generic
clone()
implementation will not work for theCustomTransferMap
. The problem is that the important property is_transfer_map
but the constructor parameter does not have the underscore in front.
Ugh ... yeah. I guess we either add a custom implementation for this special case, or rename the value of the transfer map to distinguish it from the function that every element has.
I think I'm leaning towards custom implementation. It's a little less clean, but it keeps all the names somewhat intuitive and makes for the smallest change.
I think the generic
clone()
implementation will not work for theCustomTransferMap
. The problem is that the important property is_transfer_map
but the constructor parameter does not have the underscore in front.Ugh ... yeah. I guess we either add a custom implementation for this special case, or rename the value of the transfer map to distinguish it from the function that every element has.
I think I'm leaning towards custom implementation. It's a little less clean, but it keeps all the names somewhat intuitive and makes for the smallest change.
I've implemented the second approach. There is now an override for clone()
for the CustomTransferMap
.
One more thing I've noticed: name
does not seem to be part of defining_features
for any of the elements. Cloning would therefore remove all name information at the moment.
One more thing I've noticed:
name
does not seem to be part ofdefining_features
for any of the elements. Cloning would therefore remove all name information at the moment.
It probably makes sense for that to be a defining feature of the Element
base class already, right?
Description
There is currently no reliable way to obtain copies of
Beam
orElement
. This has lead tocopy.deepcopy
being used in some places which is troublesome in some instances (see the issues linked below).Motivation and Context
225
285
Types of changes
Checklist
flake8
(required).pytest
tests pass (required).pytest
on a machine with a CUDA GPU and made sure all tests pass (required).Note: We are using a maximum length of 88 characters per line.