Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 8, 2023
1 parent d3b15ae commit f51463d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 94 deletions.
42 changes: 18 additions & 24 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,16 @@ def fetch_logo(url: str, output_path: str) -> None:

shutil.rmtree("api", ignore_errors=True)
subprocess.call(
" ".join(
[
"sphinx-apidoc",
f"../src/{PACKAGE}/",
f"../src/{PACKAGE}/version.py",
"-o api/",
"--force",
"--no-toc",
"--templatedir _templates",
"--separate",
]
),
" ".join([
"sphinx-apidoc",
f"../src/{PACKAGE}/",
f"../src/{PACKAGE}/version.py",
"-o api/",
"--force",
"--no-toc",
"--templatedir _templates",
"--separate",
]),
shell=True, # noqa: S602
)

Expand Down Expand Up @@ -189,21 +187,17 @@ def fetch_logo(url: str, output_path: str) -> None:
# General sphinx settings
add_module_names = False
autodoc_default_options = {
"exclude-members": ", ".join(
[
"items",
"keys",
"values",
]
),
"exclude-members": ", ".join([
"items",
"keys",
"values",
]),
"members": True,
"undoc-members": True,
"show-inheritance": True,
"special-members": ", ".join(
[
"__call__",
]
),
"special-members": ", ".join([
"__call__",
]),
}
autodoc_member_order = "bysource"
autodoc_type_aliases = {
Expand Down
26 changes: 11 additions & 15 deletions docs/usage/visualize.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,10 @@
"metadata": {},
"outputs": [],
"source": [
"spin_transitions = sorted(\n",
" {\n",
" t.convert(lambda s: Spin(s.particle.spin, s.spin_projection))\n",
" for t in reaction.transitions\n",
" }\n",
")\n",
"spin_transitions = sorted({\n",
" t.convert(lambda s: Spin(s.particle.spin, s.spin_projection))\n",
" for t in reaction.transitions\n",
"})\n",
"some_selection = spin_transitions[::67][:3]\n",
"dot = qrules.io.asdot(some_selection, render_node=True)\n",
"graphviz.Source(dot)"
Expand Down Expand Up @@ -537,15 +535,13 @@
" return f\"{mass}±{width}\"\n",
"\n",
"\n",
"mass_transitions = sorted(\n",
" {\n",
" t.convert(\n",
" state_converter=render_mass,\n",
" interaction_converter=lambda _: None,\n",
" )\n",
" for t in reaction.transitions\n",
" }\n",
")\n",
"mass_transitions = sorted({\n",
" t.convert(\n",
" state_converter=render_mass,\n",
" interaction_converter=lambda _: None,\n",
" )\n",
" for t in reaction.transitions\n",
"})\n",
"dot = qrules.io.asdot(mass_transitions[::10])\n",
"graphviz.Source(dot)"
]
Expand Down
10 changes: 4 additions & 6 deletions src/qrules/argument_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,10 @@ def __call__(
self,
props: GraphElementPropertyMap,
) -> Any:
return self.__class_type(
**{
arg_name: extractor(props) # type: ignore[operator]
for arg_name, extractor in self.__extractors.items()
}
)
return self.__class_type(**{
arg_name: extractor(props) # type: ignore[operator]
for arg_name, extractor in self.__extractors.items()
})


def _sequence_arg_builder(func: Callable) -> Callable[[Sequence], List[Any]]:
Expand Down
60 changes: 26 additions & 34 deletions src/qrules/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,35 +160,29 @@ def create_interaction_settings(
NodeQN.s_projection: __extend_negative(spin_magnitude_domain),
}
if formalism == "canonical-helicity":
formalism_node_settings.conservation_rules.update(
{
clebsch_gordan_helicity_to_canonical,
ls_spin_validity,
}
)
formalism_node_settings.qn_domains.update(
{
NodeQN.l_projection: [0],
NodeQN.s_projection: __extend_negative(spin_magnitude_domain),
}
)
formalism_node_settings.conservation_rules.update({
clebsch_gordan_helicity_to_canonical,
ls_spin_validity,
})
formalism_node_settings.qn_domains.update({
NodeQN.l_projection: [0],
NodeQN.s_projection: __extend_negative(spin_magnitude_domain),
})
if mass_conservation_factor is not None:
formalism_node_settings.conservation_rules.add(
MassConservation(mass_conservation_factor)
)

interaction_type_settings = {}
weak_node_settings = deepcopy(formalism_node_settings)
weak_node_settings.conservation_rules.update(
[
ChargeConservation(), # type: ignore[abstract]
ElectronLNConservation(), # type: ignore[abstract]
MuonLNConservation(), # type: ignore[abstract]
TauLNConservation(), # type: ignore[abstract]
BaryonNumberConservation(), # type: ignore[abstract]
identical_particle_symmetrization,
]
)
weak_node_settings.conservation_rules.update([
ChargeConservation(), # type: ignore[abstract]
ElectronLNConservation(), # type: ignore[abstract]
MuonLNConservation(), # type: ignore[abstract]
TauLNConservation(), # type: ignore[abstract]
BaryonNumberConservation(), # type: ignore[abstract]
identical_particle_symmetrization,
])
weak_node_settings.interaction_strength = 10 ** (-4)
weak_edge_settings = deepcopy(formalism_edge_settings)

Expand All @@ -198,15 +192,13 @@ def create_interaction_settings(
)

em_node_settings = deepcopy(weak_node_settings)
em_node_settings.conservation_rules.update(
{
CharmConservation(), # type: ignore[abstract]
StrangenessConservation(), # type: ignore[abstract]
BottomnessConservation(), # type: ignore[abstract]
parity_conservation,
c_parity_conservation,
}
)
em_node_settings.conservation_rules.update({
CharmConservation(), # type: ignore[abstract]
StrangenessConservation(), # type: ignore[abstract]
BottomnessConservation(), # type: ignore[abstract]
parity_conservation,
c_parity_conservation,
})
if "helicity" in formalism:
em_node_settings.conservation_rules.add(parity_conservation_helicity)
em_node_settings.qn_domains.update({NodeQN.parity_prefactor: [-1, 1]})
Expand All @@ -219,9 +211,9 @@ def create_interaction_settings(
)

strong_node_settings = deepcopy(em_node_settings)
strong_node_settings.conservation_rules.update(
{isospin_conservation, g_parity_conservation}
)
strong_node_settings.conservation_rules.update({
isospin_conservation, g_parity_conservation
})

strong_node_settings.interaction_strength = 60
strong_edge_settings = deepcopy(em_edge_settings)
Expand Down
14 changes: 6 additions & 8 deletions src/qrules/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,14 +739,12 @@ def create_n_body_topology(
"""
n_in = number_of_initial_states
n_out = number_of_final_states
builder = SimpleStateTransitionTopologyBuilder(
[
InteractionNode(
number_of_ingoing_edges=n_in,
number_of_outgoing_edges=n_out,
)
]
)
builder = SimpleStateTransitionTopologyBuilder([
InteractionNode(
number_of_ingoing_edges=n_in,
number_of_outgoing_edges=n_out,
)
])
topologies = builder.build(
number_of_initial_edges=n_in,
number_of_final_edges=n_out,
Expand Down
12 changes: 5 additions & 7 deletions tests/unit/test_particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,11 @@ def test_repr(self, instance: Spin, repr_method):
[(0.3, 0.3), (1.0, 0.5), (0.5, 0.0), (-0.5, 0.5)],
)
def test_exceptions(self, magnitude, projection):
regex_pattern = "|".join(
[
r"Spin magnitude \d\.\d has to be a multitude of \d\.[05]",
r"\(projection - magnitude\) should be integer",
r"Spin magnitude has to be positive",
]
)
regex_pattern = "|".join([
r"Spin magnitude \d\.\d has to be a multitude of \d\.[05]",
r"\(projection - magnitude\) should be integer",
r"Spin magnitude has to be positive",
])
regex_pattern = f"({regex_pattern})"
with pytest.raises(ValueError, match=regex_pattern):
print(Spin(magnitude, projection)) # noqa: T201
Expand Down

0 comments on commit f51463d

Please sign in to comment.