Skip to content

Commit

Permalink
refactor: improve coefficient symbol name
Browse files Browse the repository at this point in the history
The coefficients in canonical amplitudes ended in ";", while the
coefficients for helicity amplitudes did not. Furthermore, an
additional space has been added behind each intermediate ";" for
readability.
  • Loading branch information
redeboer committed May 7, 2021
1 parent 9d98a3c commit cdec30b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/ampform/helicity.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,19 @@ def generate_unique_amplitude_name(
nodelist = frozenset({node_id})
else:
nodelist = graph.topology.nodes
names: List[str] = []
for node in nodelist:
(in_hel_info, out_hel_info) = self._retrieve_helicity_info(
graph, node
)

name += (
name = (
_generate_particles_string(in_hel_info)
+ R" \to "
+ _generate_particles_string(out_hel_info)
+ ";"
)
return name[:-1]
names.append(name)
return "; ".join(names)

@staticmethod
def _retrieve_helicity_info(
Expand Down Expand Up @@ -270,13 +271,13 @@ def generate_sequential_amplitude_suffix(
self, graph: StateTransitionGraph[ParticleWithSpin]
) -> str:
"""Generate unique suffix for a sequential amplitude graph."""
output_suffix = ""
coefficient_names: List[str] = []
for node_id in graph.topology.nodes:
suffix = self.generate_amplitude_coefficient_name(graph, node_id)
if suffix in self.parity_partner_coefficient_mapping:
suffix = self.parity_partner_coefficient_mapping[suffix]
output_suffix += suffix + ";"
return output_suffix[:-1]
coefficient_names.append(suffix)
return "; ".join(coefficient_names)


class _CanonicalAmplitudeNameGenerator(_HelicityAmplitudeNameGenerator):
Expand All @@ -285,20 +286,20 @@ def generate_unique_amplitude_name(
graph: StateTransitionGraph[ParticleWithSpin],
node_id: Optional[int] = None,
) -> str:
name = ""
if isinstance(node_id, int):
node_ids = frozenset({node_id})
else:
node_ids = graph.topology.nodes
names: List[str] = []
for node in node_ids:
helicity_name = super().generate_unique_amplitude_name(graph, node)
name += (
name = (
helicity_name[:-1]
+ self._generate_clebsch_gordan_string(graph, node)
+ helicity_name[-1]
+ ";"
)
return name
names.append(name)
return "; ".join(names)

@staticmethod
def _generate_clebsch_gordan_string(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_angular_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def sympy_model(self) -> sp.Expr:

amplitude_model.parameter_defaults[
sp.Symbol(
"C[D_{1}(2420)^{0} \\to D^{*}(2010)^{+}_{0} \\pi^{-}_{0};"
"C[D_{1}(2420)^{0} \\to D^{*}(2010)^{+}_{0} \\pi^{-}_{0}; "
"D^{*}(2010)^{+} \\to D^{0}_{0} \\pi^{+}_{0}]"
)
] = 0.5
Expand Down

0 comments on commit cdec30b

Please sign in to comment.