Handling duplicate data during element creation #895
Replies: 1 comment 2 replies
-
Hi all. #695 refers to a case where the same quantity may be accessed through different names:
This is different from @T-Nicholls's proposal, and the motivation is the following: if a user explicitly specifies a keyword argument after the required positional arguments, there must be a good reason. For me, his goal is to overwrite the positional argument. Moreover, in the case of a quadrupole, adding a PolynomB keyword may be necessary to introduce other multipoles, it looks to me more natural to keep it unchanged and discard the positional K value. Of course this rule can be discussed and possibly modified, with the risk of breaking the backward compatibility. #695 was corrected according to this rule. Problems appearing from now on can be considered as bugs. However, this rule should be documented somewhere, I don't know where. In each element where the confict may happen? Second, we have the possibility to issue a warning if a conflict is detected in the constructor. should we do it? |
Beta Was this translation helpful? Give feedback.
-
When we have multiple values for the same thing being passed to the element constructor how should we handle it?
We already have #695 and #894 as examples of when this causes an error, but what happens in a case where no error is caused?
So in the case of
Quadrupole
the value already inPolynomB
is kept and the focusing strength passed ask
is silently discarded.I think this is also a problem, if the values are different then the user should at least be warned and told which value is being used.
As I see it, there are two options open to us:
I quite like option one, after all, if we're getting two different values for an attribute something is likely very wrong with the lattice file that the user is loading from.
However, if we settle on option two, I propose the following hierarchy for how the different sources of values should be prioritised:
kwargs
that is not the default valueThis might look something like:
What are everybody's thoughts?
Beta Was this translation helpful? Give feedback.
All reactions