From 6b004dba87d494415a71a78535c65fbe32b7c142 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Fri, 19 Jul 2024 14:37:54 +0300 Subject: [PATCH 1/9] Make add SV to ModeMixin name --- src/eko/evolution_operator/__init__.py | 2 +- src/eko/evolution_operator/__init__.py.patch | 8 ++++---- src/eko/evolution_operator/grid.py | 2 +- src/eko/scale_variations/__init__.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/eko/evolution_operator/__init__.py b/src/eko/evolution_operator/__init__.py index 1c759c5c5..16aa4bb5b 100644 --- a/src/eko/evolution_operator/__init__.py +++ b/src/eko/evolution_operator/__init__.py @@ -600,7 +600,7 @@ def quad_ker_qed( return ker -class Operator(sv.ModeMixin): +class Operator(sv.ScaleVariationModeMixin): """Internal representation of a single EKO. The actual matrices are computed upon calling :meth:`compute`. diff --git a/src/eko/evolution_operator/__init__.py.patch b/src/eko/evolution_operator/__init__.py.patch index a3bc24ec1..58c3f74fd 100644 --- a/src/eko/evolution_operator/__init__.py.patch +++ b/src/eko/evolution_operator/__init__.py.patch @@ -534,10 +534,10 @@ index 1c759c5c..5eb394d0 100644 - return ker - - - class Operator(sv.ModeMixin): + class Operator(sv.ScaleVariationModeMixin): """Internal representation of a single EKO. -@@ -780,50 +282,6 @@ class Operator(sv.ModeMixin): +@@ -780,50 +282,6 @@ class Operator(sv.ScaleVariationModeMixin): labels.extend(br.singlet_unified_labels) return labels @@ -588,7 +588,7 @@ index 1c759c5c..5eb394d0 100644 def initialize_op_members(self): """Init all operators with the identity or zeros.""" eye = OpMember( -@@ -846,10 +304,7 @@ class Operator(sv.ModeMixin): +@@ -846,10 +304,7 @@ class Operator(sv.ScaleVariationModeMixin): else: self.op_members[n] = zero.copy() @@ -600,7 +600,7 @@ index 1c759c5c..5eb394d0 100644 """Run the integration for each grid point. Parameters -@@ -864,18 +319,56 @@ class Operator(sv.ModeMixin): +@@ -864,18 +319,56 @@ class Operator(sv.ScaleVariationModeMixin): """ column = [] k, logx = log_grid diff --git a/src/eko/evolution_operator/grid.py b/src/eko/evolution_operator/grid.py index e64885418..2539c3fc7 100644 --- a/src/eko/evolution_operator/grid.py +++ b/src/eko/evolution_operator/grid.py @@ -29,7 +29,7 @@ """In particular, only the ``operator`` and ``error`` fields are expected.""" -class OperatorGrid(sv.ModeMixin): +class OperatorGrid(sv.ScaleVariationModeMixin): """Collection of evolution operators for several scales. The operator grid is the driver class of the evolution. diff --git a/src/eko/scale_variations/__init__.py b/src/eko/scale_variations/__init__.py index 4af80592b..9c43f1f9c 100644 --- a/src/eko/scale_variations/__init__.py +++ b/src/eko/scale_variations/__init__.py @@ -36,7 +36,7 @@ def sv_mode(s): return Modes.unvaried -class ModeMixin: +class ScaleVariationModeMixin: """Mixin to cast scale variation mode.""" @property From 7a6c1cc2c42bd63a42ad2e4bae4d362cd4daafb7 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Fri, 19 Jul 2024 15:15:12 +0300 Subject: [PATCH 2/9] Introduce EvoMethods --- src/eko/evolution_operator/__init__.py | 6 +++++ src/eko/kernels/__init__.py | 32 ++++++++++++++++++++++++++ src/eko/scale_variations/__init__.py | 13 ++++++----- tests/eko/kernels/test_init.py | 21 +++++++++++++++++ 4 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 tests/eko/kernels/test_init.py diff --git a/src/eko/evolution_operator/__init__.py b/src/eko/evolution_operator/__init__.py index 16aa4bb5b..8cd5829bd 100644 --- a/src/eko/evolution_operator/__init__.py +++ b/src/eko/evolution_operator/__init__.py @@ -20,6 +20,7 @@ from .. import basis_rotation as br from .. import interpolation, mellin from .. import scale_variations as sv +from ..kernels import ev_method from ..kernels import non_singlet as ns from ..kernels import non_singlet_qed as qed_ns from ..kernels import singlet as s @@ -780,6 +781,11 @@ def labels(self): labels.extend(br.singlet_unified_labels) return labels + @property + def ev_method(self): + """Return the evolution method.""" + return ev_method(self.config["method"]) + def quad_ker(self, label, logx, areas): """Return partially initialized integrand function. diff --git a/src/eko/kernels/__init__.py b/src/eko/kernels/__init__.py index 7640727b5..a10998b23 100644 --- a/src/eko/kernels/__init__.py +++ b/src/eko/kernels/__init__.py @@ -1 +1,33 @@ """The solutions to the |DGLAP| equations.""" + +import enum + + +class EvoMethods(enum.IntEnum): + """Enumerate evolution methods.""" + + ITERATE_EXACT = enum.auto() + ITERATE_EXPANDED = enum.auto() + PERTURBATIVE_EXACT = enum.auto() + PERTURBATIVE_EXPANDED = enum.auto() + TRUNCATED = enum.auto() + ORDERED_TRUNCATED = enum.auto() + DECOMPOSE_EXACT = enum.auto() + DECOMPOSE_EXPANDED = enum.auto() + + +def ev_method(s: EvoMethods) -> EvoMethods: + """Return the evolution methods. + + Parameters + ---------- + s : + string representation + + Returns + ------- + i : + int representation + + """ + return EvoMethods[s.value.upper().replace("-", "_")] diff --git a/src/eko/scale_variations/__init__.py b/src/eko/scale_variations/__init__.py index 9c43f1f9c..21d56a503 100644 --- a/src/eko/scale_variations/__init__.py +++ b/src/eko/scale_variations/__init__.py @@ -6,29 +6,30 @@ import enum +from ..io.types import ScaleVariationsMethod from . import expanded, exponentiated class Modes(enum.IntEnum): - """Enumerate scale Variation modes.""" + """Enumerate scale variation modes.""" unvaried = enum.auto() exponentiated = enum.auto() expanded = enum.auto() -def sv_mode(s): +def sv_mode(s: ScaleVariationsMethod) -> Modes: """Return the scale variation mode. Parameters ---------- - s : str + s : string representation Returns ------- - enum.IntEnum - enum representation + i : + int representation """ if s is not None: @@ -40,6 +41,6 @@ class ScaleVariationModeMixin: """Mixin to cast scale variation mode.""" @property - def sv_mode(self): + def sv_mode(self) -> Modes: """Return the scale variation mode.""" return sv_mode(self.config["ModSV"]) diff --git a/tests/eko/kernels/test_init.py b/tests/eko/kernels/test_init.py new file mode 100644 index 000000000..3717de275 --- /dev/null +++ b/tests/eko/kernels/test_init.py @@ -0,0 +1,21 @@ +from eko.io.types import EvolutionMethod +from eko.kernels import EvoMethods, ev_method + + +def test_ev_method(): + methods = { + "iterate-expanded": EvoMethods.ITERATE_EXPANDED, + "decompose-expanded": EvoMethods.DECOMPOSE_EXPANDED, + "perturbative-expanded": EvoMethods.PERTURBATIVE_EXPANDED, + "truncated": EvoMethods.TRUNCATED, + "ordered-truncated": EvoMethods.ORDERED_TRUNCATED, + "iterate-exact": EvoMethods.ITERATE_EXACT, + "decompose-exact": EvoMethods.DECOMPOSE_EXACT, + "perturbative-exact": EvoMethods.PERTURBATIVE_EXACT, + } + assert len(methods.keys()) == len(EvolutionMethod) + assert len(methods.keys()) == len(EvoMethods) + for s, i in methods.items(): + j = ev_method(EvolutionMethod(s)) + assert j == i + assert isinstance(j, int) From 5636b4a7e2e14f83ca0f5e34a24f71b53042e026 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Fri, 19 Jul 2024 15:45:25 +0300 Subject: [PATCH 3/9] Use EvoMethods in kernels --- src/eko/kernels/non_singlet.py | 27 ++++++------ src/eko/kernels/non_singlet_qed.py | 4 +- src/eko/kernels/singlet.py | 19 +++++---- src/eko/kernels/singlet_qed.py | 7 ++-- src/eko/kernels/valence_qed.py | 5 ++- tests/eko/kernels/test_kernels_QEDns.py | 3 +- tests/eko/kernels/test_kernels_QEDsinglet.py | 12 +++++- tests/eko/kernels/test_kernels_QEDvalence.py | 16 +++++-- tests/eko/kernels/test_ns.py | 32 ++++++-------- tests/eko/kernels/test_s.py | 44 ++++++++------------ 10 files changed, 87 insertions(+), 82 deletions(-) diff --git a/src/eko/kernels/non_singlet.py b/src/eko/kernels/non_singlet.py index bd5bd10f0..15b913438 100644 --- a/src/eko/kernels/non_singlet.py +++ b/src/eko/kernels/non_singlet.py @@ -4,6 +4,7 @@ import numpy as np from .. import beta +from . import EvoMethods from . import as4_evolution_integrals as as4_ei from . import evolution_integrals as ei @@ -355,7 +356,7 @@ def dispatcher( ---------- order : tuple(int,int) perturbation order - method : str + method : int method gamma_ns : numpy.ndarray non-singlet anomalous dimensions @@ -378,38 +379,38 @@ def dispatcher( # use always exact in LO if order[0] == 1: return lo_exact(gamma_ns, a1, a0, betalist) - if method == "ordered-truncated": + if method is EvoMethods.ORDERED_TRUNCATED: return eko_ordered_truncated( gamma_ns, a1, a0, betalist, order, ev_op_iterations ) - if method == "truncated": + if method is EvoMethods.TRUNCATED: return eko_truncated(gamma_ns, a1, a0, betalist, order, ev_op_iterations) # NLO if order[0] == 2: if method in [ - "iterate-expanded", - "decompose-expanded", - "perturbative-expanded", + EvoMethods.ITERATE_EXPANDED, + EvoMethods.DECOMPOSE_EXPANDED, + EvoMethods.PERTURBATIVE_EXPANDED, ]: return nlo_expanded(gamma_ns, a1, a0, betalist) - # if method in ["iterate-exact", "decompose-exact", "perturbative-exact"]: + # exact is left return nlo_exact(gamma_ns, a1, a0, betalist) # NNLO if order[0] == 3: if method in [ - "iterate-expanded", - "decompose-expanded", - "perturbative-expanded", + EvoMethods.ITERATE_EXPANDED, + EvoMethods.DECOMPOSE_EXPANDED, + EvoMethods.PERTURBATIVE_EXPANDED, ]: return nnlo_expanded(gamma_ns, a1, a0, betalist) return nnlo_exact(gamma_ns, a1, a0, betalist) # N3LO if order[0] == 4: if method in [ - "iterate-expanded", - "decompose-expanded", - "perturbative-expanded", + EvoMethods.ITERATE_EXPANDED, + EvoMethods.DECOMPOSE_EXPANDED, + EvoMethods.PERTURBATIVE_EXPANDED, ]: return n3lo_expanded(gamma_ns, a1, a0, betalist) return n3lo_exact(gamma_ns, a1, a0, betalist) diff --git a/src/eko/kernels/non_singlet_qed.py b/src/eko/kernels/non_singlet_qed.py index 7a2de816a..d81d5076b 100644 --- a/src/eko/kernels/non_singlet_qed.py +++ b/src/eko/kernels/non_singlet_qed.py @@ -146,7 +146,7 @@ def as4_exact(gamma_ns, a1, a0, beta): @nb.njit(cache=True) def dispatcher( order, - method, + _method, gamma_ns, as_list, aem_half, @@ -164,7 +164,7 @@ def dispatcher( ---------- order : tuple(int,int) perturbation order - method : str + method : int method gamma_ns : numpy.ndarray non-singlet anomalous dimensions diff --git a/src/eko/kernels/singlet.py b/src/eko/kernels/singlet.py index 5983c0c67..e637af046 100644 --- a/src/eko/kernels/singlet.py +++ b/src/eko/kernels/singlet.py @@ -6,6 +6,7 @@ from ekore import anomalous_dimensions as ad from .. import beta +from . import EvoMethods from . import as4_evolution_integrals as as4_ei from . import evolution_integrals as ei @@ -579,7 +580,7 @@ def dispatcher( # pylint: disable=too-many-return-statements ---------- order : tuple(int,int) perturbative order - method : str + method : int method gamma_singlet : numpy.ndarray singlet anomalous dimensions matrices @@ -609,9 +610,9 @@ def dispatcher( # pylint: disable=too-many-return-statements return lo_exact(gamma_singlet, a1, a0, betalist) # Common method for NLO and NNLO - if method in ["iterate-exact", "iterate-expanded"]: + if method in [EvoMethods.ITERATE_EXACT, EvoMethods.ITERATE_EXPANDED]: return eko_iterate(gamma_singlet, a1, a0, betalist, order, ev_op_iterations) - if method == "perturbative-exact": + if method is EvoMethods.PERTURBATIVE_EXACT: return eko_perturbative( gamma_singlet, a1, @@ -622,7 +623,7 @@ def dispatcher( # pylint: disable=too-many-return-statements ev_op_max_order, True, ) - if method == "perturbative-expanded": + if method is EvoMethods.PERTURBATIVE_EXPANDED: return eko_perturbative( gamma_singlet, a1, @@ -633,19 +634,19 @@ def dispatcher( # pylint: disable=too-many-return-statements ev_op_max_order, False, ) - if method in ["truncated", "ordered-truncated"]: + if method in [EvoMethods.TRUNCATED, EvoMethods.ORDERED_TRUNCATED]: return eko_truncated(gamma_singlet, a1, a0, betalist, order, ev_op_iterations) # These methods are scattered for nlo and nnlo - if method == "decompose-exact": + if method is EvoMethods.DECOMPOSE_EXACT: if order[0] == 2: return nlo_decompose_exact(gamma_singlet, a1, a0, betalist) - elif order[0] == 3: + if order[0] == 3: return nnlo_decompose_exact(gamma_singlet, a1, a0, betalist) return n3lo_decompose_exact(gamma_singlet, a1, a0, nf) - if method == "decompose-expanded": + if method is EvoMethods.DECOMPOSE_EXPANDED: if order[0] == 2: return nlo_decompose_expanded(gamma_singlet, a1, a0, betalist) - elif order[0] == 3: + if order[0] == 3: return nnlo_decompose_expanded(gamma_singlet, a1, a0, betalist) return n3lo_decompose_expanded(gamma_singlet, a1, a0, nf) raise NotImplementedError("Selected method is not implemented") diff --git a/src/eko/kernels/singlet_qed.py b/src/eko/kernels/singlet_qed.py index c13dee95c..2f2ba8eee 100644 --- a/src/eko/kernels/singlet_qed.py +++ b/src/eko/kernels/singlet_qed.py @@ -6,6 +6,7 @@ from ekore import anomalous_dimensions as ad from .. import beta +from . import EvoMethods @nb.njit(cache=True) @@ -66,7 +67,7 @@ def dispatcher( a_half, nf, ev_op_iterations, - ev_op_max_order, + _ev_op_max_order, ): """Determine used kernel and call it. @@ -74,7 +75,7 @@ def dispatcher( ---------- order : tuple(int,int) perturbative order - method : str + method : int method gamma_singlet : numpy.ndarray singlet anomalous dimensions matrices @@ -96,7 +97,7 @@ def dispatcher( e_s : numpy.ndarray singlet EKO """ - if method in ["iterate-exact", "iterate-expanded"]: + if method in [EvoMethods.ITERATE_EXACT, EvoMethods.ITERATE_EXPANDED]: return eko_iterate( gamma_singlet, as_list, a_half, nf, order, ev_op_iterations, 4 ) diff --git a/src/eko/kernels/valence_qed.py b/src/eko/kernels/valence_qed.py index 0d5b747c3..074dd95ed 100644 --- a/src/eko/kernels/valence_qed.py +++ b/src/eko/kernels/valence_qed.py @@ -2,6 +2,7 @@ import numba as nb +from . import EvoMethods from .singlet_qed import eko_iterate @@ -14,7 +15,7 @@ def dispatcher( a_half, nf, ev_op_iterations, - ev_op_max_order, + _ev_op_max_order, ): """ Determine used kernel and call it. @@ -45,7 +46,7 @@ def dispatcher( e_v : numpy.ndarray singlet EKO """ - if method in ["iterate-exact", "iterate-expanded"]: + if method in [EvoMethods.ITERATE_EXACT, EvoMethods.ITERATE_EXPANDED]: return eko_iterate( gamma_valence, as_list, a_half, nf, order, ev_op_iterations, 2 ) diff --git a/tests/eko/kernels/test_kernels_QEDns.py b/tests/eko/kernels/test_kernels_QEDns.py index bb18c3e17..9fce3097b 100644 --- a/tests/eko/kernels/test_kernels_QEDns.py +++ b/tests/eko/kernels/test_kernels_QEDns.py @@ -3,6 +3,7 @@ from eko import basis_rotation as br from eko.couplings import Couplings +from eko.kernels import EvoMethods from eko.kernels import non_singlet_qed as ns from eko.quantities.couplings import CouplingEvolutionMethod, CouplingsInfo from eko.quantities.heavy_quarks import QuarkMassScheme @@ -14,7 +15,7 @@ # "perturbative-expanded", # "truncated", # "ordered-truncated", - "iterate-exact", + EvoMethods.ITERATE_EXACT, # "decompose-exact", # "perturbative-exact", ] diff --git a/tests/eko/kernels/test_kernels_QEDsinglet.py b/tests/eko/kernels/test_kernels_QEDsinglet.py index b953c053c..2fee4e17f 100644 --- a/tests/eko/kernels/test_kernels_QEDsinglet.py +++ b/tests/eko/kernels/test_kernels_QEDsinglet.py @@ -1,6 +1,7 @@ import numpy as np import pytest +from eko.kernels import EvoMethods from eko.kernels import singlet_qed as s from ekore.anomalous_dimensions.unpolarized import space_like as ad @@ -10,7 +11,7 @@ # "perturbative-expanded", # "truncated", # "ordered-truncated", - "iterate-exact", + EvoMethods.ITERATE_EXACT, # "decompose-exact", # "perturbative-exact", ] @@ -125,5 +126,12 @@ def test_zero_true_gamma(monkeypatch): def test_error(): with pytest.raises(NotImplementedError): s.dispatcher( - (3, 2), "AAA", np.random.rand(4, 3, 2, 2), [0.2, 0.1], [0.01], 3, 10, 10 + (3, 2), + "iterate-exact", + np.random.rand(4, 3, 2, 2), + [0.2, 0.1], + [0.01], + 3, + 10, + 10, ) diff --git a/tests/eko/kernels/test_kernels_QEDvalence.py b/tests/eko/kernels/test_kernels_QEDvalence.py index 29f0f3d7a..4b12a492b 100644 --- a/tests/eko/kernels/test_kernels_QEDvalence.py +++ b/tests/eko/kernels/test_kernels_QEDvalence.py @@ -1,6 +1,7 @@ import numpy as np import pytest +from eko.kernels import EvoMethods from eko.kernels import valence_qed as val from ekore import anomalous_dimensions @@ -10,13 +11,13 @@ # "perturbative-expanded", # "truncated", # "ordered-truncated", - "iterate-exact", + EvoMethods.ITERATE_EXACT, # "decompose-exact", # "perturbative-exact", ] -def test_zero(monkeypatch): +def test_zero(): """No evolution results in exp(0)""" nf = 3 ev_op_iterations = 2 @@ -57,7 +58,7 @@ def test_zero(monkeypatch): ) -def test_zero_true_gamma(monkeypatch): +def test_zero_true_gamma(): """No evolution results in exp(0)""" nf = 3 ev_op_iterations = 2 @@ -101,5 +102,12 @@ def test_zero_true_gamma(monkeypatch): def test_error(): with pytest.raises(NotImplementedError): val.dispatcher( - (3, 2), "AAA", np.random.rand(4, 3, 2, 2), [0.2, 0.1], [0.01], 3, 10, 10 + (3, 2), + "iterate-exact", + np.random.rand(4, 3, 2, 2), + [0.2, 0.1], + [0.01], + 3, + 10, + 10, ) diff --git a/tests/eko/kernels/test_ns.py b/tests/eko/kernels/test_ns.py index f78282142..70e7faf8d 100644 --- a/tests/eko/kernels/test_ns.py +++ b/tests/eko/kernels/test_ns.py @@ -5,19 +5,9 @@ import ekore.anomalous_dimensions.unpolarized.space_like as ad from eko import beta +from eko.kernels import EvoMethods from eko.kernels import non_singlet as ns -methods = [ - "iterate-expanded", - "decompose-expanded", - "perturbative-expanded", - "truncated", - "ordered-truncated", - "iterate-exact", - "decompose-exact", - "perturbative-exact", -] - def test_zero(): """No evolution results in exp(0)""" @@ -25,7 +15,7 @@ def test_zero(): ev_op_iterations = 2 gamma_ns = np.array([1 + 0.0j, 1 + 0j, 1 + 0j, 1 + 0j]) for order in [1, 2, 3, 4]: - for method in methods: + for method in EvoMethods: np.testing.assert_allclose( ns.dispatcher( (order, 0), method, gamma_ns, 1.0, 1.0, nf, ev_op_iterations @@ -54,7 +44,7 @@ def test_ode_lo(): a0 = 0.3 for a1 in [0.1, 0.2]: r = a1 * gamma_ns / (beta.beta_qcd((2, 0), nf) * a1**2) - for method in methods: + for method in EvoMethods: rhs = r * ns.dispatcher( (1, 0), method, gamma_ns, a1, a0, nf, ev_op_iterations ) @@ -91,7 +81,7 @@ def test_ode_nlo(): r = (a1 * gamma_ns[0] + a1**2 * gamma_ns[1]) / ( beta.beta_qcd((2, 0), nf) * a1**2 + beta.beta_qcd((3, 0), nf) * a1**3 ) - for method in ["iterate-exact"]: + for method in [EvoMethods.ITERATE_EXACT]: rhs = r * ns.dispatcher( (2, 0), method, gamma_ns, a1, a0, nf, ev_op_iterations ) @@ -130,7 +120,7 @@ def test_ode_nnlo(): + beta.beta_qcd((3, 0), nf) * a1**2 + beta.beta_qcd((4, 0), nf) * a1**3 ) - for method in ["iterate-exact"]: + for method in [EvoMethods.ITERATE_EXACT]: rhs = r * ns.dispatcher( (3, 0), method, gamma_ns, a1, a0, nf, ev_op_iterations ) @@ -172,7 +162,7 @@ def test_ode_n3lo(): + beta.beta_qcd((4, 0), nf) * a1**3 + beta.beta_qcd((5, 0), nf) * a1**4 ) - for method in ["iterate-exact"]: + for method in [EvoMethods.ITERATE_EXACT]: rhs = r * ns.dispatcher( (4, 0), method, gamma_ns, a1, a0, nf, ev_op_iterations ) @@ -202,7 +192,9 @@ def test_ode_n3lo(): def test_error(monkeypatch): monkeypatch.setattr("eko.beta.beta_qcd", lambda *_args: 1.0) with pytest.raises(NotImplementedError, match="order is not implemented"): - ns.dispatcher((5, 0), "iterate-exact", np.random.rand(3) + 0j, 0.2, 0.1, 3, 10) + ns.dispatcher( + (5, 0), EvoMethods.ITERATE_EXACT, np.random.rand(3) + 0j, 0.2, 0.1, 3, 10 + ) with pytest.raises(NotImplementedError): ad.gamma_ns((2, 0), 10202, 1, (0, 0, 0, 0, 0, 0, 0), 3) @@ -216,7 +208,7 @@ def test_gamma_usage(): gamma_ns = np.full(4, np.nan) for order in range(1, 5): gamma_ns[order - 1] = np.random.rand() - for method in methods: + for method in EvoMethods: r = ns.dispatcher( (order, 0), method, gamma_ns, a1, a0, nf, ev_op_iterations ) @@ -225,8 +217,8 @@ def test_gamma_usage(): for order in range(1, 5): gamma_ns = np.random.rand(order) gamma_ns[order - 1] = np.nan - for method in methods: - if method == "ordered-truncated": + for method in EvoMethods: + if method is EvoMethods.ORDERED_TRUNCATED: # we are actually dividing by a np.nan, # since the sum of U vec is nan warnings.simplefilter("ignore", RuntimeWarning) diff --git a/tests/eko/kernels/test_s.py b/tests/eko/kernels/test_s.py index 5380ba319..ff4fdfc0d 100644 --- a/tests/eko/kernels/test_s.py +++ b/tests/eko/kernels/test_s.py @@ -3,20 +3,10 @@ import numpy as np import pytest +from eko.kernels import EvoMethods from eko.kernels import singlet as s from ekore import anomalous_dimensions as ad -methods = [ - "iterate-expanded", - "decompose-expanded", - "perturbative-expanded", - "truncated", - "ordered-truncated", - "iterate-exact", - "decompose-exact", - "perturbative-exact", -] - def test_zero_lo(monkeypatch): """No evolution results in exp(0)""" @@ -35,7 +25,7 @@ def test_zero_lo(monkeypatch): np.array([[0, 0], [0, 1]]), ), ) - for method in methods: + for method in EvoMethods: np.testing.assert_allclose( s.dispatcher( (1, 0), method, gamma_s, 1, 1, nf, ev_op_iterations, ev_op_max_order @@ -75,8 +65,8 @@ def test_zero_nlo_decompose(monkeypatch): ), ) for method in [ - "decompose-expanded", - "decompose-exact", + EvoMethods.DECOMPOSE_EXPANDED, + EvoMethods.DECOMPOSE_EXACT, ]: np.testing.assert_allclose( s.dispatcher( @@ -117,8 +107,8 @@ def test_zero_nnlo_decompose(monkeypatch): ), ) for method in [ - "decompose-expanded", - "decompose-exact", + EvoMethods.DECOMPOSE_EXPANDED, + EvoMethods.DECOMPOSE_EXACT, ]: np.testing.assert_allclose( s.dispatcher( @@ -159,8 +149,8 @@ def test_zero_n3lo_decompose(monkeypatch): ), ) for method in [ - "decompose-expanded", - "decompose-exact", + EvoMethods.DECOMPOSE_EXPANDED, + EvoMethods.DECOMPOSE_EXACT, ]: np.testing.assert_allclose( s.dispatcher( @@ -200,7 +190,7 @@ def test_similarity(): ]: ref = s.dispatcher( order, - "decompose-exact", + EvoMethods.DECOMPOSE_EXACT, gamma_s, a1, a0, @@ -208,7 +198,7 @@ def test_similarity(): ev_op_iterations, ev_op_max_order, ) - for method in methods: + for method in EvoMethods: np.testing.assert_allclose( s.dispatcher( order, @@ -227,7 +217,9 @@ def test_similarity(): def test_error(): with pytest.raises(NotImplementedError): - s.dispatcher((4, 0), "AAA", np.random.rand(3, 2, 2), 0.2, 0.1, 3, 10, 10) + s.dispatcher( + (4, 0), "iterate-exact", np.random.rand(3, 2, 2), 0.2, 0.1, 3, 10, 10 + ) def mk_almost_diag_matrix(n, max_ang=np.pi / 8.0): @@ -247,7 +239,7 @@ def test_gamma_usage(): gamma_s = np.full((4, 2, 2), np.nan) for order in range(1, 5): gamma_s[order - 1] = mk_almost_diag_matrix(1) - for method in methods: + for method in EvoMethods: r = s.dispatcher( (order, 0), method, @@ -263,8 +255,8 @@ def test_gamma_usage(): for order in range(1, 5): gamma_s = mk_almost_diag_matrix(4) gamma_s[order - 1] = np.full((2, 2), np.nan) - for method in methods: - if "iterate" in method: + for method in EvoMethods: + if method in [EvoMethods.ITERATE_EXACT, EvoMethods.ITERATE_EXPANDED]: # we are actually dividing by the determinant of # matrix full of np.nan warnings.simplefilter("ignore", RuntimeWarning) @@ -287,8 +279,8 @@ def test_singlet_back(): nf = 4 a1 = 3.0 a0 = 4.0 - s10 = s.dispatcher(order, "iterate-exact", gamma_s, a1, a0, nf, 15, 1) + s10 = s.dispatcher(order, EvoMethods.ITERATE_EXACT, gamma_s, a1, a0, nf, 15, 1) np.testing.assert_allclose( np.linalg.inv(s10), - s.dispatcher(order, "iterate-exact", gamma_s, a0, a1, nf, 15, 1), + s.dispatcher(order, EvoMethods.ITERATE_EXACT, gamma_s, a0, a1, nf, 15, 1), ) From db2ef3ed63894e806b78e4c0ff41281179a3ac64 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Fri, 19 Jul 2024 16:03:51 +0300 Subject: [PATCH 4/9] Use EvoMethods in ev_op --- src/eko/evolution_operator/__init__.py | 5 ++- tests/eko/evolution_operator/test_init.py | 43 ++++++++++++++------- tests/eko/scale_variations/test_diff.py | 4 +- tests/eko/scale_variations/test_expanded.py | 4 +- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/eko/evolution_operator/__init__.py b/src/eko/evolution_operator/__init__.py index 8cd5829bd..ec56b6db6 100644 --- a/src/eko/evolution_operator/__init__.py +++ b/src/eko/evolution_operator/__init__.py @@ -20,6 +20,7 @@ from .. import basis_rotation as br from .. import interpolation, mellin from .. import scale_variations as sv +from ..io.types import EvolutionMethod from ..kernels import ev_method from ..kernels import non_singlet as ns from ..kernels import non_singlet_qed as qed_ns @@ -784,7 +785,7 @@ def labels(self): @property def ev_method(self): """Return the evolution method.""" - return ev_method(self.config["method"]) + return ev_method(EvolutionMethod(self.config["method"])) def quad_ker(self, label, logx, areas): """Return partially initialized integrand function. @@ -809,7 +810,7 @@ def quad_ker(self, label, logx, areas): order=self.order, mode0=label[0], mode1=label[1], - method=self.config["method"], + method=self.ev_method, is_log=self.int_disp.log, logx=logx, areas=areas, diff --git a/tests/eko/evolution_operator/test_init.py b/tests/eko/evolution_operator/test_init.py index 597f645f8..23395f66b 100644 --- a/tests/eko/evolution_operator/test_init.py +++ b/tests/eko/evolution_operator/test_init.py @@ -11,6 +11,7 @@ from eko.evolution_operator import Operator, quad_ker from eko.interpolation import InterpolatorDispatcher from eko.io.runcards import OperatorCard, ScaleVariationsMethod, TheoryCard +from eko.kernels import EvoMethods from eko.kernels import non_singlet as ns from eko.kernels import non_singlet_qed as qed_ns from eko.kernels import singlet as s @@ -25,7 +26,7 @@ def test_quad_ker_errors(): order=(1, 0), mode0=mode0, mode1=0, - method="", + method="iterate-exact", is_log=True, logx=np.log(0.1), areas=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], @@ -60,15 +61,29 @@ def test_quad_ker(monkeypatch): monkeypatch.setattr(qed_ns, "dispatcher", lambda *args: 1.0) monkeypatch.setattr(s, "dispatcher", lambda *args: np.identity(2)) params = [ - ((1, 0), br.non_singlet_pids_map["ns+"], 0, "", 0.0, 0.0), - ((1, 0), br.non_singlet_pids_map["ns+"], 0, "", 0.123, 1.0), - ((3, 1), br.non_singlet_pids_map["ns+u"], 0, "", 0.0, 0.0), - ((1, 0), 100, 100, "", 0.123, 1.0), - ((1, 0), 100, 21, "", 0.0, 0.0), - ((1, 1), 100, 100, "iterate-exact", 0.123, 1.0), - ((1, 1), 100, 21, "iterate-exact", 0.123, 0.0), - ((1, 1), 10200, 10200, "iterate-exact", 0.123, 1.0), - ((1, 1), 10200, 10204, "iterate-exact", 0.123, 0.0), + ((1, 0), br.non_singlet_pids_map["ns+"], 0, EvoMethods.ITERATE_EXACT, 0.0, 0.0), + ( + (1, 0), + br.non_singlet_pids_map["ns+"], + 0, + EvoMethods.ITERATE_EXACT, + 0.123, + 1.0, + ), + ( + (3, 1), + br.non_singlet_pids_map["ns+u"], + 0, + EvoMethods.ITERATE_EXACT, + 0.0, + 0.0, + ), + ((1, 0), 100, 100, EvoMethods.ITERATE_EXACT, 0.123, 1.0), + ((1, 0), 100, 21, EvoMethods.ITERATE_EXACT, 0.0, 0.0), + ((1, 1), 100, 100, EvoMethods.ITERATE_EXACT, 0.123, 1.0), + ((1, 1), 100, 21, EvoMethods.ITERATE_EXACT, 0.123, 0.0), + ((1, 1), 10200, 10200, EvoMethods.ITERATE_EXACT, 0.123, 1.0), + ((1, 1), 10200, 10204, EvoMethods.ITERATE_EXACT, 0.123, 0.0), ] for order, mode0, mode1, method, logx, res in params: for is_log in [True, False]: @@ -107,7 +122,7 @@ def test_quad_ker(monkeypatch): order=(1, 0), mode0=label[0], mode1=label[1], - method="", + method=EvoMethods.ITERATE_EXACT, is_log=True, logx=0.123, areas=np.zeros(3), @@ -143,7 +158,7 @@ def test_quad_ker(monkeypatch): order=(1, 1), mode0=label[0], mode1=label[1], - method="iterate-exact", + method=EvoMethods.ITERATE_EXACT, is_log=True, logx=0.123, areas=np.zeros(3), @@ -171,7 +186,7 @@ def test_quad_ker(monkeypatch): order=(1, 0), mode0=br.non_singlet_pids_map["ns+"], mode1=0, - method="", + method=EvoMethods.ITERATE_EXACT, is_log=True, logx=0.0, areas=np.zeros(3), @@ -436,7 +451,7 @@ def quad_ker_pegasus( order = (2, 0) mode0 = br.non_singlet_pids_map["ns+"] mode1 = 0 - method = "" + method = EvoMethods.ITERATE_EXACT logxs = np.log(int_disp.xgrid.raw) a1 = 1 a0 = 2 diff --git a/tests/eko/scale_variations/test_diff.py b/tests/eko/scale_variations/test_diff.py index c0dd67236..8ade8bcac 100644 --- a/tests/eko/scale_variations/test_diff.py +++ b/tests/eko/scale_variations/test_diff.py @@ -11,7 +11,7 @@ from eko import basis_rotation as br from eko.beta import beta_qcd_as2, beta_qcd_as3 from eko.couplings import CouplingEvolutionMethod, Couplings, CouplingsInfo -from eko.kernels import non_singlet, singlet +from eko.kernels import EvoMethods, non_singlet, singlet from eko.quantities.heavy_quarks import QuarkMassScheme from eko.scale_variations import expanded, exponentiated from ekore.anomalous_dimensions.unpolarized.space_like import gamma_ns, gamma_singlet @@ -19,7 +19,7 @@ NF = 4 Q02 = 1.65**2 Q12 = 100**2 -EV_METHOD = "truncated" +EV_METHOD = EvoMethods.TRUNCATED def compute_a_s(q2, order): diff --git a/tests/eko/scale_variations/test_expanded.py b/tests/eko/scale_variations/test_expanded.py index 6af22dd51..bfacc1c96 100644 --- a/tests/eko/scale_variations/test_expanded.py +++ b/tests/eko/scale_variations/test_expanded.py @@ -2,7 +2,7 @@ from eko import basis_rotation as br from eko.couplings import CouplingEvolutionMethod, Couplings, CouplingsInfo -from eko.kernels import non_singlet, singlet +from eko.kernels import EvoMethods, non_singlet, singlet from eko.quantities.heavy_quarks import QuarkMassScheme from eko.scale_variations import Modes, expanded from ekore.anomalous_dimensions.unpolarized.space_like import gamma_ns, gamma_singlet @@ -10,7 +10,7 @@ NF = 4 Q02 = 1.65**2 Q12 = 100**2 -EV_METHOD = "truncated" +EV_METHOD = EvoMethods.TRUNCATED def compute_a_s(q2, order): From 1b1e4ce4b651033fc1c23c89cb79f42a03019c66 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Fri, 19 Jul 2024 16:41:12 +0300 Subject: [PATCH 5/9] Introduce BackwardsMethods --- .../operator_matrix_element.py | 50 ++++++++++++++++--- src/eko/kernels/__init__.py | 6 ++- tests/eko/evolution_operator/test_ome.py | 19 +++---- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/src/eko/evolution_operator/operator_matrix_element.py b/src/eko/evolution_operator/operator_matrix_element.py index 202fd18d9..b4b6731b4 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -1,6 +1,7 @@ """The |OME| for the non-trivial matching conditions in the |VFNS| evolution.""" import copy +import enum import functools import logging @@ -20,6 +21,33 @@ logger = logging.getLogger(__name__) +class BackwardsMethods(enum.IntEnum): + """Enumerate backward methods.""" + + FORWARD = enum.auto() + EXACT = enum.auto() + EXPANDED = enum.auto() + + +def bw_method(s: InversionMethod) -> BackwardsMethods: + """Return the backward method. + + Parameters + ---------- + s : + string representation + + Returns + ------- + i : + int representation + + """ + if s is not None: + return BackwardsMethods[s.value.upper()] + return BackwardsMethods.FORWARD + + @nb.njit(cache=True) def build_ome(A, matching_order, a_s, backward_method): r"""Construct the matching expansion in :math:`a_s` with the appropriate method. @@ -32,7 +60,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 or None + backward_method : BackwardsMethods empty or method for inverting the matching condition (exact or expanded) Returns @@ -51,7 +79,7 @@ def build_ome(A, matching_order, a_s, backward_method): ome = np.eye(len(A[0]), dtype=np.complex_) A = A[:, :, :] A = np.ascontiguousarray(A) - if backward_method is InversionMethod.EXPANDED: + if backward_method is BackwardsMethods.EXPANDED: # expended inverse if matching_order[0] >= 1: ome -= a_s * A[0] @@ -68,7 +96,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 is InversionMethod.EXACT: + if backward_method is BackwardsMethods.EXACT: ome = np.linalg.inv(ome) return ome @@ -216,7 +244,9 @@ class OperatorMatrixElement(Operator): def __init__(self, config, managers, nf, q2, is_backward, L, is_msbar): super().__init__(config, managers, Segment(q2, q2, nf)) - self.backward_method = config["backward_inversion"] if is_backward else None + self.backward_method = bw_method( + config["backward_inversion"] if is_backward else None + ) if is_backward: self.is_intrinsic = True else: @@ -241,7 +271,10 @@ 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 is not None: + if ( + self.is_intrinsic + or self.backward_method is not BackwardsMethods.FORWARD + ): # 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 @@ -257,7 +290,10 @@ def labels(self): (br.matching_hplus_pid, 100), ] ) - if self.is_intrinsic or self.backward_method is not None: + if ( + self.is_intrinsic + or self.backward_method is not BackwardsMethods.FORWARD + ): labels.extend( [ (21, br.matching_hplus_pid), @@ -329,7 +365,7 @@ def compute(self): self.log_label, self.order[0], self.order[1], - self.backward_method, + BackwardsMethods(self.backward_method).name, ) self.integrate() diff --git a/src/eko/kernels/__init__.py b/src/eko/kernels/__init__.py index a10998b23..594fbf1fa 100644 --- a/src/eko/kernels/__init__.py +++ b/src/eko/kernels/__init__.py @@ -2,6 +2,8 @@ import enum +from ..io.types import EvolutionMethod + class EvoMethods(enum.IntEnum): """Enumerate evolution methods.""" @@ -16,8 +18,8 @@ class EvoMethods(enum.IntEnum): DECOMPOSE_EXPANDED = enum.auto() -def ev_method(s: EvoMethods) -> EvoMethods: - """Return the evolution methods. +def ev_method(s: EvolutionMethod) -> EvoMethods: + """Return the evolution method. Parameters ---------- diff --git a/tests/eko/evolution_operator/test_ome.py b/tests/eko/evolution_operator/test_ome.py index b844290c9..584635967 100644 --- a/tests/eko/evolution_operator/test_ome.py +++ b/tests/eko/evolution_operator/test_ome.py @@ -8,6 +8,7 @@ from eko import interpolation, mellin from eko import scale_variations as sv from eko.evolution_operator.operator_matrix_element import ( + BackwardsMethods, OperatorMatrixElement, build_ome, quad_ker, @@ -33,7 +34,7 @@ def test_build_ome_as(): aS = A_singlet((o, 0), N, nf, L, is_msbar) for a in [aNS, aS]: - for method in [None, InversionMethod.EXPANDED, InversionMethod.EXACT]: + for method in BackwardsMethods: dim = len(a[0]) if o != 1: assert len(a) == o @@ -53,7 +54,7 @@ def test_build_ome_nlo(): aNSi = A_non_singlet((1, 0), N, nf, L) aSi = A_singlet((1, 0), N, nf, L, is_msbar) for a in [aNSi, aSi]: - for method in [None, InversionMethod.EXPANDED, InversionMethod.EXACT]: + for method in BackwardsMethods: dim = len(a[0]) # hh assert a[0, -1, -1] != 0.0 @@ -86,7 +87,7 @@ def test_quad_ker_errors(): is_log=True, logx=0.123, areas=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], - backward_method=None, + backward_method=BackwardsMethods.FORWARD, a_s=0.0, nf=3, L=0.0, @@ -119,7 +120,7 @@ def test_quad_ker(monkeypatch): is_log=is_log, logx=0.123, areas=np.zeros(3), - backward_method=None, + backward_method=BackwardsMethods.FORWARD, a_s=0.0, nf=3, L=0.0, @@ -138,7 +139,7 @@ def test_quad_ker(monkeypatch): is_log=is_log, logx=0.123, areas=np.zeros(3), - backward_method=None, + backward_method=BackwardsMethods.FORWARD, a_s=0.0, nf=3, L=0.0, @@ -157,7 +158,7 @@ def test_quad_ker(monkeypatch): is_log=is_log, logx=0.0, areas=np.zeros(3), - backward_method=None, + backward_method=BackwardsMethods.FORWARD, a_s=0.0, nf=3, L=0.0, @@ -191,7 +192,7 @@ def test_quad_ker(monkeypatch): is_log=True, logx=0.123, areas=np.zeros(3), - backward_method=InversionMethod.EXPANDED, + backward_method=BackwardsMethods.EXPANDED, a_s=0.0, nf=3, L=0.0, @@ -228,7 +229,7 @@ def test_quad_ker(monkeypatch): is_log=True, logx=0.123, areas=np.zeros(3), - backward_method=InversionMethod.EXACT, + backward_method=BackwardsMethods.EXACT, a_s=0.0, nf=3, L=0.0, @@ -252,7 +253,7 @@ def test_quad_ker(monkeypatch): is_log=True, logx=0.0, areas=np.array([0.01, 0.1, 1.0]), - backward_method=None, + backward_method=BackwardsMethods.FORWARD, a_s=0.0, nf=3, L=0.0, From c88627f71da3df6780692cbcc1bd04c37d0776ae Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Mon, 22 Jul 2024 13:23:45 +0300 Subject: [PATCH 6/9] Rename matching method --- .../operator_matrix_element.py | 34 ++++++++----------- src/ekomark/data/operators.py | 2 +- tests/eko/evolution_operator/test_ome.py | 20 +++++------ 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/eko/evolution_operator/operator_matrix_element.py b/src/eko/evolution_operator/operator_matrix_element.py index b4b6731b4..cf6cbcb97 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -21,16 +21,16 @@ logger = logging.getLogger(__name__) -class BackwardsMethods(enum.IntEnum): +class MatchingMethods(enum.IntEnum): """Enumerate backward methods.""" FORWARD = enum.auto() - EXACT = enum.auto() - EXPANDED = enum.auto() + BACKWARD_EXACT = enum.auto() + BACKWARD_EXPANDED = enum.auto() -def bw_method(s: InversionMethod) -> BackwardsMethods: - """Return the backward method. +def matching_method(s: InversionMethod) -> MatchingMethods: + """Return the matching method. Parameters ---------- @@ -44,8 +44,8 @@ def bw_method(s: InversionMethod) -> BackwardsMethods: """ if s is not None: - return BackwardsMethods[s.value.upper()] - return BackwardsMethods.FORWARD + return MatchingMethods[s.value.upper()] + return MatchingMethods.FORWARD @nb.njit(cache=True) @@ -60,7 +60,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 : BackwardsMethods + backward_method : MatchingMethods empty or method for inverting the matching condition (exact or expanded) Returns @@ -79,7 +79,7 @@ def build_ome(A, matching_order, a_s, backward_method): ome = np.eye(len(A[0]), dtype=np.complex_) A = A[:, :, :] A = np.ascontiguousarray(A) - if backward_method is BackwardsMethods.EXPANDED: + if backward_method is MatchingMethods.BACKWARD_EXPANDED: # expended inverse if matching_order[0] >= 1: ome -= a_s * A[0] @@ -96,7 +96,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 is BackwardsMethods.EXACT: + if backward_method is MatchingMethods.BACKWARD_EXACT: ome = np.linalg.inv(ome) return ome @@ -244,7 +244,7 @@ class OperatorMatrixElement(Operator): def __init__(self, config, managers, nf, q2, is_backward, L, is_msbar): super().__init__(config, managers, Segment(q2, q2, nf)) - self.backward_method = bw_method( + self.backward_method = matching_method( config["backward_inversion"] if is_backward else None ) if is_backward: @@ -271,10 +271,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 is not BackwardsMethods.FORWARD - ): + if self.is_intrinsic or self.backward_method is not MatchingMethods.FORWARD: # 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 @@ -290,10 +287,7 @@ def labels(self): (br.matching_hplus_pid, 100), ] ) - if ( - self.is_intrinsic - or self.backward_method is not BackwardsMethods.FORWARD - ): + if self.is_intrinsic or self.backward_method is not MatchingMethods.FORWARD: labels.extend( [ (21, br.matching_hplus_pid), @@ -365,7 +359,7 @@ def compute(self): self.log_label, self.order[0], self.order[1], - BackwardsMethods(self.backward_method).name, + MatchingMethods(self.backward_method).name, ) self.integrate() diff --git a/src/ekomark/data/operators.py b/src/ekomark/data/operators.py index ad928574d..03ad4d349 100644 --- a/src/ekomark/data/operators.py +++ b/src/ekomark/data/operators.py @@ -15,7 +15,7 @@ ev_op_max_order=10, ev_op_iterations=10, backward_inversion="expanded", - n_integration_cores=0, + n_integration_cores=1, debug_skip_non_singlet=False, debug_skip_singlet=False, mugrid=[10], diff --git a/tests/eko/evolution_operator/test_ome.py b/tests/eko/evolution_operator/test_ome.py index 584635967..553e5823c 100644 --- a/tests/eko/evolution_operator/test_ome.py +++ b/tests/eko/evolution_operator/test_ome.py @@ -8,7 +8,7 @@ from eko import interpolation, mellin from eko import scale_variations as sv from eko.evolution_operator.operator_matrix_element import ( - BackwardsMethods, + MatchingMethods, OperatorMatrixElement, build_ome, quad_ker, @@ -34,7 +34,7 @@ def test_build_ome_as(): aS = A_singlet((o, 0), N, nf, L, is_msbar) for a in [aNS, aS]: - for method in BackwardsMethods: + for method in MatchingMethods: dim = len(a[0]) if o != 1: assert len(a) == o @@ -54,7 +54,7 @@ def test_build_ome_nlo(): aNSi = A_non_singlet((1, 0), N, nf, L) aSi = A_singlet((1, 0), N, nf, L, is_msbar) for a in [aNSi, aSi]: - for method in BackwardsMethods: + for method in MatchingMethods: dim = len(a[0]) # hh assert a[0, -1, -1] != 0.0 @@ -87,7 +87,7 @@ def test_quad_ker_errors(): is_log=True, logx=0.123, areas=[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], - backward_method=BackwardsMethods.FORWARD, + backward_method=MatchingMethods.FORWARD, a_s=0.0, nf=3, L=0.0, @@ -120,7 +120,7 @@ def test_quad_ker(monkeypatch): is_log=is_log, logx=0.123, areas=np.zeros(3), - backward_method=BackwardsMethods.FORWARD, + backward_method=MatchingMethods.FORWARD, a_s=0.0, nf=3, L=0.0, @@ -139,7 +139,7 @@ def test_quad_ker(monkeypatch): is_log=is_log, logx=0.123, areas=np.zeros(3), - backward_method=BackwardsMethods.FORWARD, + backward_method=MatchingMethods.FORWARD, a_s=0.0, nf=3, L=0.0, @@ -158,7 +158,7 @@ def test_quad_ker(monkeypatch): is_log=is_log, logx=0.0, areas=np.zeros(3), - backward_method=BackwardsMethods.FORWARD, + backward_method=MatchingMethods.FORWARD, a_s=0.0, nf=3, L=0.0, @@ -192,7 +192,7 @@ def test_quad_ker(monkeypatch): is_log=True, logx=0.123, areas=np.zeros(3), - backward_method=BackwardsMethods.EXPANDED, + backward_method=MatchingMethods.BACKWARD_EXPANDED, a_s=0.0, nf=3, L=0.0, @@ -229,7 +229,7 @@ def test_quad_ker(monkeypatch): is_log=True, logx=0.123, areas=np.zeros(3), - backward_method=BackwardsMethods.EXACT, + backward_method=MatchingMethods.BACKWARD_EXACT, a_s=0.0, nf=3, L=0.0, @@ -253,7 +253,7 @@ def test_quad_ker(monkeypatch): is_log=True, logx=0.0, areas=np.array([0.01, 0.1, 1.0]), - backward_method=BackwardsMethods.FORWARD, + backward_method=MatchingMethods.FORWARD, a_s=0.0, nf=3, L=0.0, From d4a3f71889822f0311f342ec2d3ca97c049acf8f Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Mon, 22 Jul 2024 13:29:41 +0300 Subject: [PATCH 7/9] Fix MatchingMethods doc string --- 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 cf6cbcb97..87c76183a 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -22,7 +22,7 @@ class MatchingMethods(enum.IntEnum): - """Enumerate backward methods.""" + """Enumerate matching methods.""" FORWARD = enum.auto() BACKWARD_EXACT = enum.auto() From 7f079bc6001ac3f38d0d55ebd0a3cd271da7e976 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Mon, 22 Jul 2024 15:12:05 +0300 Subject: [PATCH 8/9] Fix matching renaming --- 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 87c76183a..25e5df2dd 100644 --- a/src/eko/evolution_operator/operator_matrix_element.py +++ b/src/eko/evolution_operator/operator_matrix_element.py @@ -44,7 +44,7 @@ def matching_method(s: InversionMethod) -> MatchingMethods: """ if s is not None: - return MatchingMethods[s.value.upper()] + return MatchingMethods["BACKWARD_" + s.value.upper()] return MatchingMethods.FORWARD From e40acaec28c4212d5a3ffb809ece959d415c2016 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Wed, 24 Jul 2024 15:10:40 +0300 Subject: [PATCH 9/9] Allow only iterate-exact for QED --- src/eko/kernels/singlet_qed.py | 2 +- src/eko/kernels/valence_qed.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/eko/kernels/singlet_qed.py b/src/eko/kernels/singlet_qed.py index 2f2ba8eee..d63a2f1ac 100644 --- a/src/eko/kernels/singlet_qed.py +++ b/src/eko/kernels/singlet_qed.py @@ -97,7 +97,7 @@ def dispatcher( e_s : numpy.ndarray singlet EKO """ - if method in [EvoMethods.ITERATE_EXACT, EvoMethods.ITERATE_EXPANDED]: + if method is EvoMethods.ITERATE_EXACT: return eko_iterate( gamma_singlet, as_list, a_half, nf, order, ev_op_iterations, 4 ) diff --git a/src/eko/kernels/valence_qed.py b/src/eko/kernels/valence_qed.py index 074dd95ed..186c70219 100644 --- a/src/eko/kernels/valence_qed.py +++ b/src/eko/kernels/valence_qed.py @@ -24,7 +24,7 @@ def dispatcher( ---------- order : tuple(int,int) perturbative order - method : str + method : int method gamma_singlet : numpy.ndarray singlet anomalous dimensions matrices @@ -46,7 +46,7 @@ def dispatcher( e_v : numpy.ndarray singlet EKO """ - if method in [EvoMethods.ITERATE_EXACT, EvoMethods.ITERATE_EXPANDED]: + if method is EvoMethods.ITERATE_EXACT: return eko_iterate( gamma_valence, as_list, a_half, nf, order, ev_op_iterations, 2 )