From 61cc2904acc3b451c9c0bd95faa36a58599c8c3f Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Thu, 26 Nov 2020 14:07:09 +0100 Subject: [PATCH 01/10] fix: remove default dynamics --- docs/conf.py | 2 +- docs/usage/1_create_model.ipynb | 18 ++++++++++++++++++ setup.cfg | 2 +- .../physics/helicity_formalism/amplitude.py | 3 --- tests/conftest.py | 5 ++++- tests/recipe/test_amplitude_creation.py | 4 ++-- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 6aef4a71..93d5aa08 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -135,7 +135,7 @@ # Intersphinx settings intersphinx_mapping = { "expertsystem": ( - "https://pwa.readthedocs.io/projects/expertsystem/en/0.6.3", + "https://pwa.readthedocs.io/projects/expertsystem/en/0.6.4", None, ), "iminuit": ("https://iminuit.readthedocs.io/en/latest", None), diff --git a/docs/usage/1_create_model.ipynb b/docs/usage/1_create_model.ipynb index 07ee212e..83e62786 100644 --- a/docs/usage/1_create_model.ipynb +++ b/docs/usage/1_create_model.ipynb @@ -92,6 +92,24 @@ "list(model.parameters)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note that we have to specify the dynamics for the resonances. We choose to use {class}`~expertsystem.amplitude.model.RelativisticBreitWigner` for all resonances:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for name in result.get_intermediate_particles().names:\n", + " model.dynamics.set_breit_wigner(name)\n", + "{name: type(dyn) for name, dyn in model.dynamics.items()}" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/setup.cfg b/setup.cfg index d5555989..7f4a2239 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,7 @@ setup_requires = setuptools_scm install_requires = amplitf==0.0.1a2 - expertsystem==0.6.3 + expertsystem==0.6.4 iminuit==1.4.5 numpy==1.18.0 pandas==1.0.5 diff --git a/src/tensorwaves/physics/helicity_formalism/amplitude.py b/src/tensorwaves/physics/helicity_formalism/amplitude.py index ecd2f90f..fdae5fb2 100644 --- a/src/tensorwaves/physics/helicity_formalism/amplitude.py +++ b/src/tensorwaves/physics/helicity_formalism/amplitude.py @@ -155,9 +155,6 @@ def create_dynamics( """Create a dynamics function callable.""" if self._dynamics is None: raise ValueError("Dynamics has not yet been set") - - if decaying_state.name not in self._dynamics: - self._dynamics.set_breit_wigner(decaying_state.name) decay_dynamics = self._dynamics[decaying_state.name] kwargs = {} diff --git a/tests/conftest.py b/tests/conftest.py index 51b42331..6e81d593 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,4 +34,7 @@ def __create_model(formalism: str) -> AmplitudeModel: allowed_interaction_types=["EM", "strong"], number_of_threads=1, ) - return es.generate_amplitudes(result) + model = es.generate_amplitudes(result) + for name in result.get_intermediate_particles().names: + model.dynamics.set_breit_wigner(name) + return model diff --git a/tests/recipe/test_amplitude_creation.py b/tests/recipe/test_amplitude_creation.py index 1c423f39..aaaf26ce 100644 --- a/tests/recipe/test_amplitude_creation.py +++ b/tests/recipe/test_amplitude_creation.py @@ -33,7 +33,7 @@ def test_helicity(helicity_model: es.AmplitudeModel): builder = IntensityBuilder(model.particles, kinematics, phsp_sample) intensity = builder.create_intensity(model) - assert len(intensity.parameters) == 9 + assert len(intensity.parameters) == 10 def test_canonical(canonical_model: es.AmplitudeModel): @@ -43,4 +43,4 @@ def test_canonical(canonical_model: es.AmplitudeModel): phsp_sample = _generate_phsp(model, NUMBER_OF_PHSP_EVENTS) builder = IntensityBuilder(particles, kinematics, phsp_sample) intensity = builder.create_intensity(model) - assert len(intensity.parameters) == 9 + assert len(intensity.parameters) == 10 From 10e115ee6214d0679896f16f89fb600f397ac296 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Thu, 26 Nov 2020 14:08:25 +0100 Subject: [PATCH 02/10] TEMP build: use expertsystem PR branches --- docs/conf.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 93d5aa08..02534feb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -135,7 +135,7 @@ # Intersphinx settings intersphinx_mapping = { "expertsystem": ( - "https://pwa.readthedocs.io/projects/expertsystem/en/0.6.4", + "https://pwa--395.org.readthedocs.build/projects/expertsystem/en/395", None, ), "iminuit": ("https://iminuit.readthedocs.io/en/latest", None), diff --git a/setup.cfg b/setup.cfg index 7f4a2239..d809306e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,7 @@ setup_requires = setuptools_scm install_requires = amplitf==0.0.1a2 - expertsystem==0.6.4 + expertsystem @ git+https://github.com/redeboer/expertsystem@breit-wigner iminuit==1.4.5 numpy==1.18.0 pandas==1.0.5 From ef2cefb0fadd299dde43f41e9ab0b3e4ac7eef59 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Thu, 26 Nov 2020 20:47:34 +0100 Subject: [PATCH 03/10] Revert "TEMP build: use expertsystem PR branches" This reverts commit 10e115ee6214d0679896f16f89fb600f397ac296. --- docs/conf.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 02534feb..93d5aa08 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -135,7 +135,7 @@ # Intersphinx settings intersphinx_mapping = { "expertsystem": ( - "https://pwa--395.org.readthedocs.build/projects/expertsystem/en/395", + "https://pwa.readthedocs.io/projects/expertsystem/en/0.6.4", None, ), "iminuit": ("https://iminuit.readthedocs.io/en/latest", None), diff --git a/setup.cfg b/setup.cfg index d809306e..7f4a2239 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,7 @@ setup_requires = setuptools_scm install_requires = amplitf==0.0.1a2 - expertsystem @ git+https://github.com/redeboer/expertsystem@breit-wigner + expertsystem==0.6.4 iminuit==1.4.5 numpy==1.18.0 pandas==1.0.5 From 4eccf5abe4695c7e9fa3fa9211df0b1eddacaf00 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Thu, 26 Nov 2020 20:58:47 +0100 Subject: [PATCH 04/10] fix: link to develop PWA pages section --- docs/install.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install.md b/docs/install.md index 6f9a17a1..557bb10b 100644 --- a/docs/install.md +++ b/docs/install.md @@ -33,7 +33,7 @@ This goes as follows: 3. Install the project in {ref}`'editable installation' ` with - {ref}`additional dependencies ` for the + {ref}`additional dependencies ` for the developer: ```shell From 75fe1f816999119d0204607e7e4af2e82f4755c1 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Thu, 26 Nov 2020 21:04:11 +0100 Subject: [PATCH 05/10] fix: adapt workflow test to es 0.6.4 --- examples/intensity-recipe.yaml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/intensity-recipe.yaml b/examples/intensity-recipe.yaml index 700c5511..9d1b2fce 100644 --- a/examples/intensity-recipe.yaml +++ b/examples/intensity-recipe.yaml @@ -61,6 +61,16 @@ Parameters: - Name: &par16 Phase_J/psi_to_f0(1500)_0+gamma_-1;f(0)(1500)_to_pi0_0+pi0_0; Type: Phase Value: 0.0 + - Name: &par17 MesonRadius_J/psi + Value: 1.0 + - Name: &par18 MesonRadius_f(0)(980) + Value: 1.0 + - Name: &par19 MesonRadius_f(2)(1270) + Value: 1.0 + - Name: &par20 MesonRadius_f(0)(1500) + Value: 1.0 + - Name: &par21 MesonRadius_f(2)(1950) + Value: 1.0 Intensity: Class: NormalizedIntensity @@ -1165,28 +1175,28 @@ Dynamics: Type: NonDynamic FormFactor: Type: BlattWeisskopf - MesonRadius: 1.0 + MesonRadius: *par17 f(0)(980): Type: RelativisticBreitWigner FormFactor: Type: BlattWeisskopf - MesonRadius: 1.0 + MesonRadius: *par18 f(2)(1270): Type: RelativisticBreitWigner FormFactor: Type: BlattWeisskopf - MesonRadius: 1.0 + MesonRadius: *par19 f(0)(1500): Type: RelativisticBreitWigner FormFactor: Type: BlattWeisskopf - MesonRadius: 1.0 + MesonRadius: *par20 f(2)(1950): Type: RelativisticBreitWigner FormFactor: Type: BlattWeisskopf - MesonRadius: 1.0 + MesonRadius: *par21 From a4e9a5be1c9d88a0688a40ad9766725286e850a8 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Thu, 26 Nov 2020 21:06:07 +0100 Subject: [PATCH 06/10] fix: link to JSON schema amplitude model --- .vscode/settings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index abbfca7a..e0db188a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -65,10 +65,10 @@ "telemetry.enableCrashReporter": false, "telemetry.enableTelemetry": false, "yaml.schemas": { - "https://raw.githubusercontent.com/ComPWA/expertsystem/master/expertsystem/schemas/yaml/amplitude-model.json": [ + "https://raw.githubusercontent.com/ComPWA/expertsystem/0.6.4/src/expertsystem/schemas/yaml/amplitude-model.json": [ "*recipe.y*ml" ], - "https://raw.githubusercontent.com/ComPWA/expertsystem/master/expertsystem/schemas/yaml/particle-list.json": [ + "https://raw.githubusercontent.com/ComPWA/expertsystem/0.6.4/src/expertsystem/schemas/yaml/particle-list.json": [ "*particle.y*ml" ] } From d2d1b90a26b532bc16a132f538a43153e2e87426 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Fri, 27 Nov 2020 11:14:03 +0100 Subject: [PATCH 07/10] fix: use Position instead of Mass --- src/tensorwaves/physics/helicity_formalism/amplitude.py | 2 +- tests/recipe/test_amplitude_creation.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tensorwaves/physics/helicity_formalism/amplitude.py b/src/tensorwaves/physics/helicity_formalism/amplitude.py index fdae5fb2..e43e3ce0 100644 --- a/src/tensorwaves/physics/helicity_formalism/amplitude.py +++ b/src/tensorwaves/physics/helicity_formalism/amplitude.py @@ -612,7 +612,7 @@ def _create_dynamics( DynamicsProperties( orbit_angular_momentum=orbit_angular_momentum, resonance_mass=builder.register_parameter( - f"Mass_{particle.name}", + f"Position_{particle.name}", particle.mass, ), resonance_width=builder.register_parameter( diff --git a/tests/recipe/test_amplitude_creation.py b/tests/recipe/test_amplitude_creation.py index aaaf26ce..1c423f39 100644 --- a/tests/recipe/test_amplitude_creation.py +++ b/tests/recipe/test_amplitude_creation.py @@ -33,7 +33,7 @@ def test_helicity(helicity_model: es.AmplitudeModel): builder = IntensityBuilder(model.particles, kinematics, phsp_sample) intensity = builder.create_intensity(model) - assert len(intensity.parameters) == 10 + assert len(intensity.parameters) == 9 def test_canonical(canonical_model: es.AmplitudeModel): @@ -43,4 +43,4 @@ def test_canonical(canonical_model: es.AmplitudeModel): phsp_sample = _generate_phsp(model, NUMBER_OF_PHSP_EVENTS) builder = IntensityBuilder(particles, kinematics, phsp_sample) intensity = builder.create_intensity(model) - assert len(intensity.parameters) == 10 + assert len(intensity.parameters) == 9 From c666dd865020da8a35314588be3e05091a8789a8 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Fri, 27 Nov 2020 11:18:05 +0100 Subject: [PATCH 08/10] test: parameter names --- tests/recipe/test_amplitude_creation.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/recipe/test_amplitude_creation.py b/tests/recipe/test_amplitude_creation.py index 1c423f39..adb82df7 100644 --- a/tests/recipe/test_amplitude_creation.py +++ b/tests/recipe/test_amplitude_creation.py @@ -33,7 +33,17 @@ def test_helicity(helicity_model: es.AmplitudeModel): builder = IntensityBuilder(model.particles, kinematics, phsp_sample) intensity = builder.create_intensity(model) - assert len(intensity.parameters) == 9 + assert set(intensity.parameters) == { + "strength_incoherent", + "Position_J/psi(1S)", + "Width_J/psi(1S)", + "MesonRadius_J/psi(1S)", + "Magnitude_J/psi(1S)_to_f(0)(980)_0+gamma_1;f(0)(980)_to_pi0_0+pi0_0;", + "Phase_J/psi(1S)_to_f(0)(980)_0+gamma_1;f(0)(980)_to_pi0_0+pi0_0;", + "Position_f(0)(980)", + "Width_f(0)(980)", + "MesonRadius_f(0)(980)", + } def test_canonical(canonical_model: es.AmplitudeModel): @@ -43,4 +53,14 @@ def test_canonical(canonical_model: es.AmplitudeModel): phsp_sample = _generate_phsp(model, NUMBER_OF_PHSP_EVENTS) builder = IntensityBuilder(particles, kinematics, phsp_sample) intensity = builder.create_intensity(model) - assert len(intensity.parameters) == 9 + assert set(intensity.parameters) == { + "strength_incoherent", + "Position_J/psi(1S)", + "Width_J/psi(1S)", + "MesonRadius_J/psi(1S)", + "Magnitude_J/psi(1S)_to_f(0)(980)_0+gamma_1;f(0)(980)_to_pi0_0+pi0_0;", + "Phase_J/psi(1S)_to_f(0)(980)_0+gamma_1;f(0)(980)_to_pi0_0+pi0_0;", + "Position_f(0)(980)", + "Width_f(0)(980)", + "MesonRadius_f(0)(980)", + } From 180ac42017c1e2a46d193bda8861895c0060b6ec Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Fri, 27 Nov 2020 11:25:39 +0100 Subject: [PATCH 09/10] fix: upgrade Jupyter code formatter --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 7f4a2239..9cd94693 100644 --- a/setup.cfg +++ b/setup.cfg @@ -114,7 +114,7 @@ tox = tox==3.20.1 tools = jupyterlab==2.2.9 - jupyterlab_code_formatter==1.3.6 + jupyterlab_code_formatter==1.3.8 labels==20.1.0 dev = %(doc)s From 9d4e16f3a1e60ede45006f6810a8d64b2db59825 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Fri, 27 Nov 2020 11:27:34 +0100 Subject: [PATCH 10/10] fix: use Position parameter in notebook --- docs/usage/3_perform_fit.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/usage/3_perform_fit.ipynb b/docs/usage/3_perform_fit.ipynb index 2e9a5691..011c0d9f 100644 --- a/docs/usage/3_perform_fit.ipynb +++ b/docs/usage/3_perform_fit.ipynb @@ -140,9 +140,9 @@ "initial_parameters = {\n", " \"Phase_J/psi(1S)_to_f(0)(1500)_0+gamma_1;f(0)(1500)_to_pi0_0+pi0_0;\": 0.0,\n", " \"Width_f(0)(500)\": 0.1,\n", - " \"Mass_f(0)(980)\": 0.9,\n", - " \"Mass_f(0)(1500)\": 1.55,\n", - " \"Mass_f(0)(1710)\": 1.8,\n", + " \"Position_f(0)(980)\": 0.9,\n", + " \"Position_f(0)(1500)\": 1.55,\n", + " \"Position_f(0)(1710)\": 1.8,\n", " \"Width_f(0)(1710)\": 0.3,\n", "}" ]