The bug
Setting a value to a zero-length magnet does not raise an error. It fails silently and the readback gives nan.
As pyaml uses integrated strength, I think we should be able to deal with this case.
Or if we don't want to deal with this, at least this would be checked and forbiden at the configuration level or raise a proper error.
How to reproduce
With a lattice with the following corrector magnet:
atcorrector('COR_003', 0.0, [0. 0.], 'MaxOrder', 1, 'NumIntSteps', 1, 'PolynomA', [0.], 'PolynomB', [0.]);...
You can write the following pyaml configuration:
- type: pyaml.magnet.cfm_magnet
name: COR_003
mapping:
- [B0, COR_003.hcorrector]
- [A0, COR_003.vcorrector]
model:
type: pyaml.magnet.identity_cfm_model
multipoles: [B0, A0]
units: ['1', '1']
physics:
- ANS-C01/AE/S4-CH/currentPM
- ANS-C01/AE/S4-CV/currentPM
You can load it into pyaml without error and select the magnet, get its strengh:
hcor = sr.design.magnet.get("COR_003.hcorrector")
hcor.strength.get()
>>> np.float64(-0.0)
But when you try to set, the value with be stuck to nan:
hcor.strength.set(1e-6)
hcor.strength.get()
>>> np.float64(nan)
The bug
Setting a value to a zero-length magnet does not raise an error. It fails silently and the readback gives nan.
As pyaml uses integrated strength, I think we should be able to deal with this case.
Or if we don't want to deal with this, at least this would be checked and forbiden at the configuration level or raise a proper error.
How to reproduce
With a lattice with the following corrector magnet:
You can write the following pyaml configuration:
You can load it into pyaml without error and select the magnet, get its strengh:
But when you try to set, the value with be stuck to nan: