From fbfa8895cebdaa66f7eb2d5eb24b0962271a4333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Thu, 20 Apr 2023 16:37:06 +0200 Subject: [PATCH 1/8] Fix backward matching in build_ome --- src/eko/evolution_operator/operator_matrix_element.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/eko/evolution_operator/operator_matrix_element.py b/src/eko/evolution_operator/operator_matrix_element.py index 95e4ddff9..b3542c164 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -49,7 +49,7 @@ def build_ome(A, matching_order, a_s, backward_method): # .end ome = np.eye(len(A[0]), dtype=np.complex_) A = np.ascontiguousarray(A) - if backward_method == "expanded": + if backward_method.value == "expanded": # expended inverse if matching_order[0] >= 1: ome -= a_s * A[0] @@ -66,7 +66,7 @@ def build_ome(A, matching_order, a_s, backward_method): if matching_order[0] >= 3: ome += a_s**3 * A[2] # need inverse exact ? so add the missing pieces - if backward_method == "exact": + if backward_method.value == "exact": ome = np.linalg.inv(ome) return ome From 6674afbe84f50d77935e2a2fb15a43e0b385cd0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Thu, 20 Apr 2023 17:25:29 +0200 Subject: [PATCH 2/8] Fix ifs --- src/eko/evolution_operator/operator_matrix_element.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/eko/evolution_operator/operator_matrix_element.py b/src/eko/evolution_operator/operator_matrix_element.py index b3542c164..3a89b27de 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -14,6 +14,7 @@ from .. import basis_rotation as br from .. import scale_variations as sv +from ..io.types import InversionMethod from . import Operator, QuadKerBase logger = logging.getLogger(__name__) @@ -49,7 +50,7 @@ def build_ome(A, matching_order, a_s, backward_method): # .end ome = np.eye(len(A[0]), dtype=np.complex_) A = np.ascontiguousarray(A) - if backward_method.value == "expanded": + if backward_method is InversionMethod.EXPANDED: # expended inverse if matching_order[0] >= 1: ome -= a_s * A[0] @@ -66,7 +67,7 @@ def build_ome(A, matching_order, a_s, backward_method): if matching_order[0] >= 3: ome += a_s**3 * A[2] # need inverse exact ? so add the missing pieces - if backward_method.value == "exact": + if backward_method is InversionMethod.EXACT: ome = np.linalg.inv(ome) return ome From a336ec1cd417b6dbf099a4475b0b0c4c9519bcad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Thu, 20 Apr 2023 17:30:10 +0200 Subject: [PATCH 3/8] Fix test_matchin_condition.py -> test_matching_condition.py --- .../{test_matchin_condition.py => test_matching_condition.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/eko/evolution_operator/{test_matchin_condition.py => test_matching_condition.py} (100%) diff --git a/tests/eko/evolution_operator/test_matchin_condition.py b/tests/eko/evolution_operator/test_matching_condition.py similarity index 100% rename from tests/eko/evolution_operator/test_matchin_condition.py rename to tests/eko/evolution_operator/test_matching_condition.py From 33e6c76187503d62d3de0bc5af47d4f5b89367bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Fri, 21 Apr 2023 10:13:34 +0200 Subject: [PATCH 4/8] Fix docstrings --- src/eko/evolution_operator/operator_matrix_element.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/eko/evolution_operator/operator_matrix_element.py b/src/eko/evolution_operator/operator_matrix_element.py index 3a89b27de..41ef0c6f4 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -32,7 +32,7 @@ def build_ome(A, matching_order, a_s, backward_method): perturbation matching order a_s : float strong coupling, needed only for the exact inverse - backward_method : ["exact", "expanded" or ""] + backward_method : [InversionMethod.EXACT, InversionMethod.EXPANDED or ""] empty or method for inverting the matching condition (exact or expanded) Returns @@ -115,7 +115,7 @@ def quad_ker( number of active flavor below threshold L : float :math:``\ln(\mu_F^2 / m_h^2)`` - backward_method : ["exact", "expanded" or ""] + backward_method : [InversionMethod.EXACT, InversionMethod.EXPANDED or ""] empty or method for inverting the matching condition (exact or expanded) is_msbar: bool add the |MSbar| contribution From 4c99185770aec332d0a10bc4e269211b06341569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Fri, 21 Apr 2023 10:17:48 +0200 Subject: [PATCH 5/8] Fix test_ome --- tests/eko/evolution_operator/test_ome.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/eko/evolution_operator/test_ome.py b/tests/eko/evolution_operator/test_ome.py index 2c0fdf644..16900d814 100644 --- a/tests/eko/evolution_operator/test_ome.py +++ b/tests/eko/evolution_operator/test_ome.py @@ -41,7 +41,7 @@ def test_build_ome_as(): aS = A_singlet((o, 0), N, sx_singlet, nf, L, is_msbar, sx_ns) for a in [aNS, aS]: - for method in ["", "expanded", "exact"]: + for method in ["", InversionMethod.EXPANDED, InversionMethod.EXACT]: dim = len(a[0]) if o != 1: assert len(a) == o @@ -62,7 +62,7 @@ def test_build_ome_nlo(): aNSi = A_non_singlet((1, 0), N, sx, nf, L) aSi = A_singlet((1, 0), N, sx, nf, L, is_msbar) for a in [aNSi, aSi]: - for method in ["", "expanded", "exact"]: + for method in ["", InversionMethod.EXPANDED, InversionMethod.EXACT]: dim = len(a[0]) # hh assert a[0, -1, -1] != 0.0 @@ -197,7 +197,7 @@ def test_quad_ker(monkeypatch): is_log=True, logx=0.123, areas=np.zeros(3), - backward_method="expanded", + backward_method=InversionMethod.EXPANDED, a_s=0.0, nf=3, L=0.0, @@ -234,7 +234,7 @@ def test_quad_ker(monkeypatch): is_log=True, logx=0.123, areas=np.zeros(3), - backward_method="exact", + backward_method=InversionMethod.EXACT, a_s=0.0, nf=3, L=0.0, From 5303949d187da9767ddbbe6f767094828fe67256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= <57321974+niclaurenti@users.noreply.github.com> Date: Fri, 21 Apr 2023 10:21:13 +0200 Subject: [PATCH 6/8] Update src/eko/evolution_operator/operator_matrix_element.py Co-authored-by: Alessandro Candido --- src/eko/evolution_operator/operator_matrix_element.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eko/evolution_operator/operator_matrix_element.py b/src/eko/evolution_operator/operator_matrix_element.py index 41ef0c6f4..8abf253b8 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -32,7 +32,7 @@ def build_ome(A, matching_order, a_s, backward_method): perturbation matching order a_s : float strong coupling, needed only for the exact inverse - backward_method : [InversionMethod.EXACT, InversionMethod.EXPANDED or ""] + backward_method : InversionMethod or None empty or method for inverting the matching condition (exact or expanded) Returns From e2e04bce64ec8bff1dc50dbbfe552e1a60886ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Fri, 21 Apr 2023 10:23:16 +0200 Subject: [PATCH 7/8] Use None instead of --- src/eko/evolution_operator/operator_matrix_element.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/eko/evolution_operator/operator_matrix_element.py b/src/eko/evolution_operator/operator_matrix_element.py index 8abf253b8..620b4dd20 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -115,7 +115,7 @@ def quad_ker( number of active flavor below threshold L : float :math:``\ln(\mu_F^2 / m_h^2)`` - backward_method : [InversionMethod.EXACT, InversionMethod.EXPANDED or ""] + backward_method : InversionMethod or None empty or method for inverting the matching condition (exact or expanded) is_msbar: bool add the |MSbar| contribution @@ -141,7 +141,7 @@ def quad_ker( ) sx_ns = sx.copy() if order[0] == 3 and ( - (backward_method != "" and ker_base.is_singlet) + (backward_method is not None and ker_base.is_singlet) or (mode0 == 100 and mode1 == 100) ): # At N3LO for A_qq singlet or backward you need to compute @@ -241,7 +241,7 @@ class OperatorMatrixElement(Operator): def __init__(self, config, managers, nf, q2, is_backward, L, is_msbar): super().__init__(config, managers, nf, q2, None) - self.backward_method = config["backward_inversion"] if is_backward else "" + self.backward_method = config["backward_inversion"] if is_backward else None if is_backward: self.is_intrinsic = True else: @@ -266,7 +266,7 @@ def labels(self): logger.warning("%s: skipping non-singlet sector", self.log_label) else: labels.append((200, 200)) - if self.is_intrinsic or self.backward_method != "": + if self.is_intrinsic or self.backward_method is not None: # intrinsic labels, which are not zero at NLO labels.append((br.matching_hminus_pid, br.matching_hminus_pid)) # These contributions are always 0 for the moment @@ -282,7 +282,7 @@ def labels(self): (br.matching_hplus_pid, 100), ] ) - if self.is_intrinsic or self.backward_method != "": + if self.is_intrinsic or self.backward_method is not None: labels.extend( [ (21, br.matching_hplus_pid), From f08143cd5f2258ad6fb51a5e66f31063bd63f2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Laurenti?= Date: Fri, 21 Apr 2023 10:24:49 +0200 Subject: [PATCH 8/8] Do the same in the tests --- tests/eko/evolution_operator/test_ome.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/eko/evolution_operator/test_ome.py b/tests/eko/evolution_operator/test_ome.py index 16900d814..86b8cff83 100644 --- a/tests/eko/evolution_operator/test_ome.py +++ b/tests/eko/evolution_operator/test_ome.py @@ -41,7 +41,7 @@ def test_build_ome_as(): aS = A_singlet((o, 0), N, sx_singlet, nf, L, is_msbar, sx_ns) for a in [aNS, aS]: - for method in ["", InversionMethod.EXPANDED, InversionMethod.EXACT]: + for method in [None, InversionMethod.EXPANDED, InversionMethod.EXACT]: dim = len(a[0]) if o != 1: assert len(a) == o @@ -62,7 +62,7 @@ def test_build_ome_nlo(): aNSi = A_non_singlet((1, 0), N, sx, nf, L) aSi = A_singlet((1, 0), N, sx, nf, L, is_msbar) for a in [aNSi, aSi]: - for method in ["", InversionMethod.EXPANDED, InversionMethod.EXACT]: + for method in [None, InversionMethod.EXPANDED, InversionMethod.EXACT]: dim = len(a[0]) # hh assert a[0, -1, -1] != 0.0 @@ -306,7 +306,7 @@ def test_quad_ker(monkeypatch): # "debug_skip_non_singlet": False, # "ev_op_max_order": 1, # "ev_op_iterations": 1, -# "backward_inversion": "", +# "backward_inversion": None, # } # g = OperatorGrid.from_dict( # theory_card, @@ -327,7 +327,7 @@ def test_quad_ker(monkeypatch): # order=theory_card["PTO"], # L=0, # nf=4, -# backward_method="", +# backward_method=None, # is_msbar=False, # )