Add support for parsing decay descriptors#573
Conversation
|
Hi @admorris, I am not forgetting to check this. It's just that I have been working on urgent and important suff. Will get back to you very soon. |
| return cls(mother, decay_modes) | ||
|
|
||
| @classmethod | ||
| def from_string( |
There was a problem hiding this comment.
At some point it would make sense to "synchronise" this from_string function with the existing to_string one, since they should effectively be the "mirror of each other". Else one would name this function to from_descriptor. WDYT?
There was a problem hiding this comment.
The pytest test_from_string_to_string demonstrates they mirror eachother in the specific case of using the default grammar.
What if this function is renamed from_descriptor, then from_string just invokes from_descriptor with the default grammar?
There was a problem hiding this comment.
Yes, that sounds good to me.
eduardo-rodrigues
left a comment
There was a problem hiding this comment.
Thank you so much for this, @admorris! It's a really nice enhancement 👍.
I left a few little suggestions but this is looking excellent anway.
I am well aware of the limitation you point out. It does annoy me.
|
Hey @admorris, let me know your thoughts on this enhancement and whether you would prefer to have a follow-up for the limitations and some of the matters discussed above. BTW, for the issue with parsing parenthesis for particle names. One thing that differentiates parentheses for particle names wrt parenthesis denoting decays is that the latter always contain an arrow inside, so between ( and ). |
|
Hey. So aside the trivial comment above, I think there are only 2 things to get sorted:$
|
|
Hi @admorris, you may have seen the major improvements made to the package recently, thanks to @henryiii. We are moving towards a 1.0 release ... Let me know if you will be able to pick up the work here after a rebase. FYI you can now do the following: |
|
Very good! I will have a look |
Co-authored-by: Eduardo Rodrigues <eduardo.rodrigues@cern.ch>
2943a59 to
c8eb6de
Compare
|
Whenever you are ready, I can do an Opus 4.8 or GPT 5.5 review of the PR if that sounds helpful. (if you are using one of those, or already ran a review with one, let me know and I'll do the other one, otherwise I'll do Opus because I've got higher limits on that) |
Implements the rest of #200
Added
DecayChain.from_stringmethodDecay descriptors are parsed with Lark. A
Transformerclass converts them intoDecayChainDictobjects, which are then used to initialiseDecayChainobjects.Custom descriptor formats can be used by pointing to another
.larkfile in an argument ofDecayChain.from_string. These pretty much only have the freedom to modifyARROW,LPARandRPAR. The rest of the structure is assumed by the Transformer. i.e. I did not find a way to support sub-decays written with the mother outside of braces likeA -> B (-> C D) EOne glaring limitation (which is inherent to
DecayChain/_build_decay_modes) is that sub-decays of identically named particles are not supported: e.g.."B_s0 -> (phi -> K+ K-) (phi -> K+ K-)"will result in an exception. This could possibly be handled by adding internal/hidden uniqueness when duplicates are encountered.