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

Formulate List[StateTransitionGraph] in terms of a class #26

Closed
redeboer opened this issue Oct 16, 2020 · 5 comments · Fixed by #75
Closed

Formulate List[StateTransitionGraph] in terms of a class #26

redeboer opened this issue Oct 16, 2020 · 5 comments · Fixed by #75
Assignees
Labels
⚠️ Interface Breaking changes to the API
Milestone

Comments

@redeboer
Copy link
Member

I think it would be safer to wrap the allowed transitions (currently represent by a list of StateTransitionGraphs) into a class, something like StateTransition. This object can then contain more advanced methods to give info about the list of StateTransitionGraphs it contains, as well as some checks when adding new StateTransitionGraphs (for instance to enforce that the initial state and final state particles are consistent).

The idea is that a StateTransition instance becomes the product that the reaction module delivers.

@redeboer redeboer self-assigned this Oct 16, 2020
@redeboer
Copy link
Member Author

@spflueger moving the discussion of ComPWA/expertsystem#328 (review) here for now

The Result class currently provides:

  1. solutions (List[StateTransitionGraph[ParticleWithSpin]])
  2. violated_rules
  3. not_executed_rules
  4. formalism_type (fishy that this would be necessary when computing allowed transitions, but this is another discussion)

If I understand correctly, only 1. and 4. are useful once there are solutions, while 2. and 3. are of use only when there are no solutions. To me that suggests it's better that what is currently the Result class becomes a class as suggested in this issue (a wrapper around List[StateTransitionGraph]) and that we raise a dedicated exception class (NoSolutionsFound or something) that carries violated_rules and not_executed_rules.

@redeboer
Copy link
Member Author

The formalism_type can still be contained within the returned class in case there are solutions, however, I still prefer if we get rid of formalism_type in the reaction module eventually.

@spflueger
Copy link
Member

The formalism_type can still be contained within the returned class in case there are solutions, however, I still prefer if we get rid of formalism_type in the reaction module eventually.

I thought about this a bit more. I think the only thing that makes this difficult is that the spin projections have different meanings in the different formalisms. So in the helicity formalism its helicities, while in the canonical its spin projections onto some fixed axis.

To generate a result that is "independent" of the formalism, which could be put into any of the amplitude builders. I currently do not see a way around this other than computing the spin projections in parallel. Or some kind of adapter would be needed to convert.

The good thing is that we currently do not support the canonical formalism natively, but put the canonical formalism on top of the helicity formalism (substituting helicity amps with a sum of canonical ones). Hence we only have the helicity spin projections and do not run into the problem above. Long term this problem will arise though.

@spflueger
Copy link
Member

@spflueger moving the discussion of #328 (review) here for now

The Result class currently provides:

  1. solutions (List[StateTransitionGraph[ParticleWithSpin]])
  2. violated_rules
  3. not_executed_rules
  4. formalism_type (fishy that this would be necessary when computing allowed transitions, but this is another discussion)

If I understand correctly, only 1. and 4. are useful once there are solutions, while 2. and 3. are of use only when there are no solutions. To me that suggests it's better that what is currently the Result class becomes a class as suggested in this issue (a wrapper around List[StateTransitionGraph]) and that we raise a dedicated exception class (NoSolutionsFound or something) that carries violated_rules and not_executed_rules.

Generally good concept. I don't like the code raising exceptions on common or natural cases. Not executed rules should never happen (i dont really have proof for this, but thats at least to expect as a user). Hence an exception makes perfect sense here. However violated rules are very common, and also part of the responsibility of the framework. I think it would be much nicer to have this information in the "result" somehow instead of raising an Error for that

@redeboer
Copy link
Member Author

Additional benefit: StateTransitionGraph[ParticleWithSpin] can't be 'pickled' because it uses Generic. ComPWA/expertsystem#519 mitigates it, but notes this problem in the documentation.

Still, it would be better to keep StateTransitionGraph[ParticleWithSpin] internal and have the reaction module return some frozen instance. If that output class is written with attrs, that would simplify ComPWA/expertsystem#519 further, because the serialization can be done with attr.asdict (just like it's being done for asdict on ParticleCollection).

@redeboer redeboer transferred this issue from ComPWA/expertsystem Apr 6, 2021
@redeboer redeboer added the ⚠️ Interface Breaking changes to the API label Apr 16, 2021
@redeboer redeboer added this to the 0.9.0 milestone May 27, 2021
redeboer added a commit to redeboer/ComPWA-qrules that referenced this issue Apr 30, 2022
* refactor: remove particle_list.xml attributes
* refactor!: remove XML attributes internally
* fix: input filename for write to XML
* refactor: extract load_default_particle_list
* ci: do not check docstrings in tests
* test: add I/O test for particle_list

Closes ComPWA#25, closes ComPWA#26, and closes ComPWA#31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ Interface Breaking changes to the API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants