From 0d88b5192df4d1097b03af53fad4ae38e7288aa4 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 5 Aug 2024 10:48:13 +0200 Subject: [PATCH] FIX: adjust simplification code for SymPy v1.13 --- docs/usage/dynamics/k-matrix.ipynb | 6 +++--- tests/dynamics/test_kmatrix.py | 11 ++++------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/usage/dynamics/k-matrix.ipynb b/docs/usage/dynamics/k-matrix.ipynb index b401194e2..de181e27d 100644 --- a/docs/usage/dynamics/k-matrix.ipynb +++ b/docs/usage/dynamics/k-matrix.ipynb @@ -642,9 +642,9 @@ "outputs": [], "source": [ "# reformulate terms\n", - "denominator, nominator = k_matrix.args\n", - "term1 = nominator.args[0] * denominator\n", - "term2 = nominator.args[1] * denominator\n", + "*rest, denominator, nominator = k_matrix.args\n", + "term1 = nominator.args[0] * denominator * sp.Mul(*rest)\n", + "term2 = nominator.args[1] * denominator * sp.Mul(*rest)\n", "k_matrix = term1 + term2\n", "k_matrix" ] diff --git a/tests/dynamics/test_kmatrix.py b/tests/dynamics/test_kmatrix.py index 0d1f1ddf2..bd37c3baa 100644 --- a/tests/dynamics/test_kmatrix.py +++ b/tests/dynamics/test_kmatrix.py @@ -1,16 +1,13 @@ from __future__ import annotations import re -from typing import TYPE_CHECKING import pytest +import sympy as sp from ampform.dynamics.kmatrix import NonRelativisticKMatrix from symplot import rename_symbols, substitute_indexed_symbols -if TYPE_CHECKING: - import sympy as sp - class TestNonRelativisticKMatrix: @pytest.mark.parametrize( @@ -35,9 +32,9 @@ def test_interference_single_channel(self): expr = substitute_indexed_symbols(expr) expr = _remove_residue_constants(expr) expr = _rename_widths(expr) - denominator, nominator = expr.args - term1 = nominator.args[0] * denominator - term2 = nominator.args[1] * denominator + *rest, denominator, nominator = expr.args + term1 = nominator.args[0] * denominator * sp.Mul(*rest) + term2 = nominator.args[1] * denominator * sp.Mul(*rest) assert str(term1 / term2) == R"m1*w1*(m2**2 - s)/(m2*w2*(m1**2 - s))"