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

FIX: fix is_integer() bug for QRules v0.10.4 #450

Merged
merged 35 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
11e8c1c
fixed is_integer-not-implemented bug for Python < 3.12
grayson-helmholz Jan 17, 2025
16eefa3
MAINT: implement updates from pre-commit hooks
web-flow Jan 17, 2025
775f1a6
MAINT: update lock files
web-flow Jan 17, 2025
c092fbb
removed dispatching for `float`
grayson-helmholz Jan 17, 2025
f3f7eea
Merge branch 'hotfix_fraction_is_integer_bug' of github.com:ComPWA/am…
grayson-helmholz Jan 17, 2025
db5d490
removed redundant import
grayson-helmholz Jan 17, 2025
8e5c0df
mock-test for channel
grayson-helmholz Jan 17, 2025
00f3ecc
reintroduced dispatching on spin-type to support qrules 0.9
grayson-helmholz Jan 17, 2025
0568b80
removed OS-check
grayson-helmholz Jan 17, 2025
f3def7f
MAINT: update lock files
web-flow Jan 17, 2025
4503777
renamed inner function
grayson-helmholz Jan 17, 2025
a0bcd6b
Merge branch 'hotfix_fraction_is_integer_bug' of github.com:ComPWA/am…
grayson-helmholz Jan 17, 2025
242bb78
MAINT: remove `pygments` constraint
redeboer Jan 16, 2025
523b5a5
MAINT: remove `pytest-profiling` constraint
redeboer Jan 16, 2025
deaaf78
DX: remove `setuptools-scm` version configuration
redeboer Jan 17, 2025
68d35af
MAINT: update lock files
web-flow Jan 17, 2025
6f6431c
MAINT: update lock files
redeboer Jan 22, 2025
b3e066b
MAINT: update developer environment
redeboer Jan 22, 2025
b216928
DX: run tests in `tox` on all Python versions
redeboer Jan 22, 2025
9aa5d87
FIX: use union syntax for Python 3.9
redeboer Jan 22, 2025
9b84bf5
FIX: update expected hashses for different Python versions
redeboer Jan 22, 2025
60cb60f
MAINT: test framework on Python 3.13
redeboer Jan 22, 2025
8ce23b4
DX: test package on Python 3.13
redeboer Jan 22, 2025
6f089ce
FIX: install `tox-uv` on RTD
redeboer Jan 22, 2025
5fc8ae2
MAINT: remove redundant channel test
redeboer Jan 22, 2025
e48212b
REVERT: change back to `CI` variable for hash
redeboer Jan 22, 2025
2901494
FIX: mark macos also as CI
redeboer Jan 22, 2025
dc37759
MAINT: update lock files
web-flow Jan 22, 2025
cc24e54
DX: run `tox -e uv` with lock runner
redeboer Jan 27, 2025
f5e5d4f
MAINT: update lock files
web-flow Jan 27, 2025
dd1466d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 27, 2025
a1447ab
MAINT: update lock files
redeboer Jan 28, 2025
66f2b54
MAINT: update lock files
redeboer Jan 28, 2025
e850682
FIX: set correct ignore patterns for `sphinx-autobuild`
redeboer Jan 28, 2025
2443be7
MAINT: update lock files
web-flow Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.5.15
rev: 0.5.16
hooks:
- id: check-dev-files
args:
Expand Down Expand Up @@ -60,7 +60,7 @@ repos:
metadata.vscode

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
rev: v0.9.2
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -127,7 +127,7 @@ repos:
pass_filenames: false

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.17.0
rev: v8.17.1
hooks:
- id: cspell

Expand All @@ -153,11 +153,11 @@ repos:
- python

- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.391
rev: v1.1.392
hooks:
- id: pyright

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.18
rev: 0.5.20
hooks:
- id: uv-lock
9 changes: 0 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ namespaces = false
where = ["src"]

[tool.setuptools_scm]
local_scheme = "no-local-version"
version_scheme = "only-version"
write_to = "src/ampform/version.py"

[tool.coverage.run]
Expand Down Expand Up @@ -576,10 +574,3 @@ description = "Run all notebooks with pytest"
allowlist_externals = ["pre-commit"]
commands = [["pre-commit", "run", "--all-files", {replace = "posargs", extend = true}]]
description = "Perform all linting, formatting, and spelling checks"

[tool.uv]
constraint-dependencies = [
"pygments!=2.19.*", # https://github.com/felix-hilden/sphinx-codeautolink/issues/152
"pytest-profiling!=1.8.0",
"sphinx-codeautolink!=0.16.0",
]
11 changes: 10 additions & 1 deletion src/ampform/helicity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
import warnings
from collections import OrderedDict, abc
from fractions import Fraction
from functools import reduce, singledispatchmethod
from typing import TYPE_CHECKING, Union

Expand Down Expand Up @@ -928,13 +929,21 @@
def _generate_kinematic_variable_set(
transition: StateTransition, node_id: int
) -> TwoBodyKinematicVariableSet:
def is_integer(spin: float | Fraction) -> bool:
if isinstance(spin, float):
return spin.is_integer()

Check warning on line 934 in src/ampform/helicity/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/ampform/helicity/__init__.py#L934

Added line #L934 was not covered by tests
if isinstance(spin, Fraction):
return spin.denominator == 1
msg = "spin has to of type float (qrules 0.9) or Fraction (qrules >= 0.10)"
raise TypeError(msg)

Check warning on line 938 in src/ampform/helicity/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/ampform/helicity/__init__.py#L937-L938

Added lines #L937 - L938 were not covered by tests

decay = TwoBodyDecay.from_transition(transition, node_id)
inv_mass, phi, theta = _generate_kinematic_variables(transition, node_id)
topology = transition.topology
child1_mass = get_invariant_mass_symbol(topology, decay.children[0].id)
child2_mass = get_invariant_mass_symbol(topology, decay.children[1].id)
angular_momentum: int | None = decay.interaction.l_magnitude
if angular_momentum is None and decay.parent.particle.spin.is_integer():
if angular_momentum is None and is_integer(decay.parent.particle.spin):
angular_momentum = int(decay.parent.particle.spin)
return TwoBodyKinematicVariableSet(
incoming_state_mass=inv_mass,
Expand Down
16 changes: 16 additions & 0 deletions tests/channels/test_Jpis1S_to_gamma_pi0_pi0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import qrules

from ampform import get_builder


def test_generate_model():
result = qrules.generate_transitions(
initial_state=("J/psi(1S)", [-1, +1]),
final_state=["gamma", "pi0", "pi0"],
allowed_intermediate_particles=["f(0)(980)", "f(0)(1500)"],
allowed_interaction_types=["strong", "EM"],
formalism="helicity",
)
model_builder = get_builder(result)
original_model = model_builder.formulate()
assert original_model is not None
8 changes: 2 additions & 6 deletions tests/sympy/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import logging
import os
from typing import TYPE_CHECKING, ClassVar

import pytest
Expand All @@ -18,9 +17,6 @@
from qrules.transition import SpinFormalism


_GH = "CI" in os.environ and os.uname().sysname != "Darwin"


@pytest.mark.parametrize(
("expected_hash", "assumptions"),
[
Expand Down Expand Up @@ -85,8 +81,8 @@ def test_reaction(self, expected_hash: str, formalism: SpinFormalism):
@pytest.mark.parametrize(
("expected_hash", "formalism"),
[
("87c4839" if _GH else "01bb112", "canonical-helicity"),
("c147bdd" if _GH else "0638a0e", "helicity"),
("01bb112", "canonical-helicity"),
("0638a0e", "helicity"),
],
ids=["canonical-helicity", "helicity"],
)
Expand Down
Loading
Loading