Skip to content

Commit

Permalink
Merge branch 'spin_as_fraction' of github.com:CompWA/qrules into spin…
Browse files Browse the repository at this point in the history
…_as_fraction
  • Loading branch information
grayson-helmholz committed Nov 25, 2024
2 parents 3e2ba1a + c9ad862 commit 1d1e7e0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def pick_newtype_attrs(some_type: type) -> list:
api_target_substitutions: dict[str, str | tuple[str, str]] = {
"EdgeQuantumNumberTypes": ("obj", "qrules.quantum_numbers.EdgeQuantumNumberTypes"),
"EdgeType": "typing.TypeVar",
"Fraction": "fraction.Fraction",
"Fraction": ("obj", "fractions.Fraction"),
"GraphEdgePropertyMap": ("obj", "qrules.argument_handling.GraphEdgePropertyMap"),
"GraphElementProperties": ("obj", "qrules.solving.GraphElementProperties"),
"GraphNodePropertyMap": ("obj", "qrules.argument_handling.GraphNodePropertyMap"),
Expand Down Expand Up @@ -296,7 +296,6 @@ def pick_newtype_attrs(some_type: type) -> list:
(r"py:(class|obj)", r"qrules\.topology\.NewNodeType"),
(r"py:(class|obj)", r"qrules\.topology\.NodeType"),
(r"py:(class|obj)", r"qrules\.topology\.VT"),
(r"py:(class|obj)", r"fraction\.Fraction"),
*nitpick_temp_patterns,
]
nitpicky = True
Expand Down
4 changes: 2 additions & 2 deletions src/qrules/combinatorics.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ def fill_spin_projections(state: StateDefinition) -> StateWithSpins:
particle_name = state
particle = particle_db[particle_name]
spin_projections = set(arange(-particle.spin, particle.spin + 1))
if particle.mass == 0.0 and Fraction(0, 1) in spin_projections:
spin_projections.remove(Fraction(0, 1))
if particle.mass == 0.0 and Fraction(0) in spin_projections:
spin_projections.remove(Fraction(0))
return particle_name, sorted(spin_projections)
return state

Expand Down
2 changes: 1 addition & 1 deletion src/qrules/conservation_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def calculate_hypercharge(
or edge_qns.tau_lepton_number
):
return True
isospin_3 = Fraction(0, 1)
isospin_3 = Fraction(0)
if edge_qns.isospin_projection:
isospin_3 = edge_qns.isospin_projection
return float(edge_qns.charge) == isospin_3 + 0.5 * calculate_hypercharge(edge_qns)
Expand Down
4 changes: 2 additions & 2 deletions src/qrules/particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def _validate_fraction_for_spin(
attribute: Attribute, # noqa: ARG001
value: Fraction, # noqa: ARG001
) -> Any:
if instance.magnitude % Fraction(1, 2) != Fraction(0, 1):
if instance.magnitude % Fraction(1, 2) != Fraction(0):
msg = f"Spin magnitude {instance.magnitude} has to be a multitude of 0.5"
raise ValueError(msg)
if abs(instance.projection) > instance.magnitude:
if instance.magnitude < Fraction(0, 1):
if instance.magnitude < Fraction(0):
msg = f"Spin magnitude has to be positive, but is {instance.magnitude}"
raise ValueError(msg)
msg = (
Expand Down
2 changes: 1 addition & 1 deletion src/qrules/quantum_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class InteractionProperties:


def arange(
x_1: Fraction, x_2: Fraction, delta: Fraction = Fraction(1, 1)
x_1: Fraction, x_2: Fraction, delta: Fraction = Fraction(1)
) -> Generator[Fraction, None, None]:
current = Fraction(x_1)
delta = Fraction(delta)
Expand Down

0 comments on commit 1d1e7e0

Please sign in to comment.