Skip to content

Commit

Permalink
Introduce EvoMethods
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhekhorn committed Jul 19, 2024
1 parent 6b004db commit 7a6c1cc
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/eko/evolution_operator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
32 changes: 32 additions & 0 deletions src/eko/kernels/__init__.py
Original file line number Diff line number Diff line change
@@ -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("-", "_")]
13 changes: 7 additions & 6 deletions src/eko/scale_variations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"])
21 changes: 21 additions & 0 deletions tests/eko/kernels/test_init.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7a6c1cc

Please sign in to comment.