Skip to content

Commit

Permalink
Remove unused default parameters and remove qed argument from apply_pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
niclaurenti committed Oct 10, 2023
1 parent 569a0fe commit 2f65ee9
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/eko/basis_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@
}


def ad_projector(ad_lab, nf, qed=False):
def ad_projector(ad_lab, nf, qed):
"""
Build a projector (as a numpy array) for the given anomalous dimension sector.
Expand Down Expand Up @@ -355,7 +355,7 @@ def select_light_flavors_uni_ev(ad_lab, nf):
return map_ad_to_evolution[ad_lab]


def ad_projectors(nf, qed=False):
def ad_projectors(nf, qed):
"""
Build projectors tensor (as a numpy array), collecting all the individual sector projectors.
Expand Down
8 changes: 4 additions & 4 deletions src/eko/evolution_operator/flavors.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def pids_from_intrinsic_evol(label, nf, normalize):
return weights


def get_range(evol_labels, qed=False):
def get_range(evol_labels, qed):
"""Determine the number of light and heavy flavors participating in the input and output.
Here, we assume that the T distributions (e.g. T15) appears *always*
Expand All @@ -73,7 +73,7 @@ def get_range(evol_labels, qed=False):
nf_in = 3
nf_out = 3

def update(label, qed=False):
def update(label, qed):
nf = 3
if label[0] == "T":
if not qed:
Expand Down Expand Up @@ -129,7 +129,7 @@ def rotate_pm_to_flavor(label):
return l


def rotate_matching(nf, qed=False, inverse=False):
def rotate_matching(nf, qed, inverse=False):
"""Rotation between matching basis (with e.g. S,g,...V8 and c+,c-) and new true evolution basis (with S,g,...V8,T15,V15).
Parameters
Expand Down Expand Up @@ -206,7 +206,7 @@ def rotate_matching(nf, qed=False, inverse=False):
return l


def rotate_matching_inverse(nf, qed=False):
def rotate_matching_inverse(nf, qed):
"""Inverse rotation between matching basis (with e.g. S,g,...V8 and c+,c-) and new true evolution basis (with S,g,...V8,T15,V15).
Parameters
Expand Down
2 changes: 1 addition & 1 deletion src/eko/evolution_operator/matching_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def split_ad_to_evol_map(
nf,
q2_thr,
intrinsic_range,
qed=False,
qed,
):
"""
Create the instance from the |OME|.
Expand Down
2 changes: 1 addition & 1 deletion src/eko/evolution_operator/physical.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PhysicalOperator(member.OperatorBase):
"""

@classmethod
def ad_to_evol_map(cls, op_members, nf, q2_final, intrinsic_range, qed=False):
def ad_to_evol_map(cls, op_members, nf, q2_final, intrinsic_range, qed):
"""
Obtain map between the 3-dimensional anomalous dimension basis and the 4-dimensional evolution basis.
Expand Down
11 changes: 4 additions & 7 deletions src/ekobox/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def apply_pdf(
lhapdf_like,
targetgrid=None,
rotate_to_evolution_basis=False,
qed=False,
):
"""
Apply all available operators to the input PDFs.
Expand All @@ -34,23 +33,22 @@ def apply_pdf(
out_grid : dict
output PDFs and their associated errors for the computed mu2grid
"""
qed = eko.theory_card.order[1] > 0
if rotate_to_evolution_basis:
if not qed:
rotate_flavor_to_evolution = br.rotate_flavor_to_evolution
else:
rotate_flavor_to_evolution = br.rotate_flavor_to_unified_evolution
return apply_pdf_flavor(
eko, lhapdf_like, targetgrid, rotate_flavor_to_evolution, qed
eko, lhapdf_like, targetgrid, rotate_flavor_to_evolution
)
return apply_pdf_flavor(eko, lhapdf_like, targetgrid)


CONTRACTION = "ajbk,bk"


def apply_pdf_flavor(
eko: EKO, lhapdf_like, targetgrid=None, flavor_rotation=None, qed=False
):
def apply_pdf_flavor(eko: EKO, lhapdf_like, targetgrid=None, flavor_rotation=None):
"""
Apply all available operators to the input PDFs.
Expand All @@ -65,8 +63,6 @@ def apply_pdf_flavor(
if given, interpolates to the pdfs given at targetgrid (instead of xgrid)
flavor_rotation : np.ndarray
Rotation matrix in flavor space
qed : bool
activate qed
Returns
-------
Expand Down Expand Up @@ -97,6 +93,7 @@ def apply_pdf_flavor(
if error_final is not None:
out_grid[ep]["errors"] = dict(zip(eko.bases.targetpids, error_final))

qed = eko.theory_card.order[1] > 0
# rotate to evolution basis
if flavor_rotation is not None:
for q2, op in out_grid.items():
Expand Down
1 change: 0 additions & 1 deletion src/ekomark/benchmark/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ def log(self, theory, _, pdf, me, ext):
pdf,
xgrid,
flavor_rotation=rotate_to_evolution,
qed=qed,
)
for q2, ref_pdfs in ext["values"].items():
log_tab = dfdict.DFdict()
Expand Down
16 changes: 9 additions & 7 deletions tests/eko/evolution_operator/test_flavors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ def get(d):


def test_get_range():
assert (3, 3) == flavors.get_range([])
assert (3, 3) == flavors.get_range([member.MemberName(n) for n in ["S.S", "V3.V3"]])
assert (3, 3) == flavors.get_range([], False)
assert (3, 3) == flavors.get_range(
[member.MemberName(n) for n in ["S.S", "V3.V3"]], False
)
assert (3, 4) == flavors.get_range(
[member.MemberName(n) for n in ["S.S", "V3.V3", "T15.S"]]
[member.MemberName(n) for n in ["S.S", "V3.V3", "T15.S"]], False
)
assert (4, 4) == flavors.get_range(
[member.MemberName(n) for n in ["S.S", "V3.V3", "T15.T15"]]
[member.MemberName(n) for n in ["S.S", "V3.V3", "T15.T15"]], False
)
assert (3, 3) == flavors.get_range(
[member.MemberName(n) for n in ["S.S", "Td3.Td3"]], True
Expand Down Expand Up @@ -113,7 +115,7 @@ def test_rotate_pm_to_flavor():


def test_rotate_matching():
m = flavors.rotate_matching(4)
m = flavors.rotate_matching(4, False)
assert len(list(filter(lambda e: "c+" in e, m.keys()))) == 2
assert len(list(filter(lambda e: "b-" in e, m.keys()))) == 1

Expand Down Expand Up @@ -156,8 +158,8 @@ def load(m):
return mm

for nf in range(4, 6 + 1):
m = load(flavors.rotate_matching(nf))
minv = load(flavors.rotate_matching_inverse(nf))
m = load(flavors.rotate_matching(nf, False))
minv = load(flavors.rotate_matching_inverse(nf, False))
np.testing.assert_allclose(m @ minv, np.eye(len(br.evol_basis)), atol=1e-10)


Expand Down
10 changes: 5 additions & 5 deletions tests/eko/evolution_operator/test_matching_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def update_intrinsic_OME(self, ome):

def test_split_ad_to_evol_map(self):
ome = self.mkOME()
a = MatchingCondition.split_ad_to_evol_map(ome, 3, 1, [])
a = MatchingCondition.split_ad_to_evol_map(ome, 3, 1, [], False)
triv_keys = [
"V.V",
"T3.T3",
Expand All @@ -64,7 +64,7 @@ def test_split_ad_to_evol_map(self):
ome[(200, 200)].value,
)
# # if alpha is zero, nothing non-trivial should happen
b = MatchingCondition.split_ad_to_evol_map(ome, 3, 1, [])
b = MatchingCondition.split_ad_to_evol_map(ome, 3, 1, [], False)
assert sorted(str(k) for k in b.op_members.keys()) == sorted(
[*triv_keys, *keys3]
)
Expand All @@ -74,7 +74,7 @@ def test_split_ad_to_evol_map(self):
# )
# nf=3 + IC
self.update_intrinsic_OME(ome)
c = MatchingCondition.split_ad_to_evol_map(ome, 3, 1, [4])
c = MatchingCondition.split_ad_to_evol_map(ome, 3, 1, [4], False)
assert sorted(str(k) for k in c.op_members.keys()) == sorted(
[*triv_keys, *keys3, "S.c+", "g.c+", "c+.c+", "c-.c-"]
)
Expand All @@ -83,7 +83,7 @@ def test_split_ad_to_evol_map(self):
b.op_members[member.MemberName("V.V")].value,
)
# nf=3 + IB
d = MatchingCondition.split_ad_to_evol_map(ome, 3, 1, [5])
d = MatchingCondition.split_ad_to_evol_map(ome, 3, 1, [5], False)
assert sorted(str(k) for k in d.op_members.keys()) == sorted(
[*triv_keys, *keys3, "b+.b+", "b-.b-"]
)
Expand All @@ -92,7 +92,7 @@ def test_split_ad_to_evol_map(self):
np.eye(self.shape[0]),
)
# nf=4 + IB
d = MatchingCondition.split_ad_to_evol_map(ome, 4, 1, [5])
d = MatchingCondition.split_ad_to_evol_map(ome, 4, 1, [5], False)
assert sorted(str(k) for k in d.op_members.keys()) == sorted(
[
*triv_keys,
Expand Down
8 changes: 4 additions & 4 deletions tests/eko/test_basis_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ def test_ad_projector():
g = br.rotate_flavor_to_evolution[2]
v3 = br.rotate_flavor_to_evolution[br.evol_basis.index("V3")]

s_to_s = br.ad_projector((100, 100), nf=6)
s_to_s = br.ad_projector((100, 100), nf=6, qed=False)

np.testing.assert_allclose(s @ s_to_s, s)
np.testing.assert_allclose(g @ s_to_s, 0.0)
np.testing.assert_allclose(v3 @ s_to_s, 0.0)

g_to_s = br.ad_projector((21, 100), nf=6)
g_to_s = br.ad_projector((21, 100), nf=6, qed=False)

np.testing.assert_allclose(s @ g_to_s, 0.0)
np.testing.assert_allclose(g @ g_to_s, s)
np.testing.assert_allclose(v3 @ g_to_s, 0.0)

ns_m = br.ad_projector((br.non_singlet_pids_map["ns-"], 0), nf=6)
ns_m = br.ad_projector((br.non_singlet_pids_map["ns-"], 0), nf=6, qed=False)

np.testing.assert_allclose(s @ ns_m, 0.0, atol=1e-15)
np.testing.assert_allclose(g @ ns_m, 0.0)
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_ad_projectors():
for nf in range(3, 6 + 1):
diag = np.array([0] * (1 + 6 - nf) + [1] * (1 + 2 * nf) + [0] * (6 - nf))
identity = np.diag(diag)
projs = br.ad_projectors(nf)
projs = br.ad_projectors(nf, qed=False)

# sum over diagonal projectors form an identity
np.testing.assert_allclose(
Expand Down

0 comments on commit 2f65ee9

Please sign in to comment.