Skip to content

Commit

Permalink
update regression rules for sumrules and remove unnecessary if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Feb 15, 2022
1 parent 0321658 commit 21e4fea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
18 changes: 5 additions & 13 deletions validphys2/src/validphys/sumrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ def _momentum_sum_rule_integrand(x, lpdf, Q):

def _make_momentum_fraction_integrand(fldict):
"""Make a suitable integrand function, which takes x to be integrated over
and fixed loaded PDF, replica number and Q that computes the momentum
fraction based on ``fldict``.
and a PDF member and Q that computes the momentum fraction based on ``fldict``.
The keys of ``fldict`` are free form values corresponding to PDG parton ids
(that end up being passed by :py:func:`validphys.pdfbases.parse_flarr` and
Expand Down Expand Up @@ -59,8 +58,7 @@ def f(x, lpdf, Q):

def _make_pdf_integrand(fldict):
"""Make a suitable integrand function, which takes x to be integrated over
and fixed loaded PDF, replica number and Q that computes the integrand of
the PDFs based on ``fldict``.
and a PDF member and Q that computes the integrand of the PDFs based on ``fldict``.
The keys of ``fldict`` are free form values corresponfing to PDG parton ids
(that end up being passed :py:func:`validphys.pdfbases.parse_flarr` and
Expand Down Expand Up @@ -149,10 +147,8 @@ def sum_rules(pdf:PDF, Q:numbers.Real):
SumRulesGrid object with the list of values for each sum rule. The
integration is performed with absolute and relative tolerance of 1e-4."""
lpdf = pdf.load()
tmp = _sum_rules(KNOWN_SUM_RULES, lpdf, Q)
if pdf.error_type == "replicas":
return {k: v[1:] for k,v in tmp.items()}
return tmp
return _sum_rules(KNOWN_SUM_RULES, lpdf, Q)


@check_positive('Q')
def central_sum_rules(pdf:PDF, Q:numbers.Real):
Expand All @@ -161,7 +157,6 @@ def central_sum_rules(pdf:PDF, Q:numbers.Real):
return _sum_rules(KNOWN_SUM_RULES, lpdf, Q)



@check_positive('Q')
def unknown_sum_rules(pdf: PDF, Q: numbers.Real):
"""Compute the following integrals
Expand All @@ -177,10 +172,7 @@ def unknown_sum_rules(pdf: PDF, Q: numbers.Real):
- T8
"""
lpdf = pdf.load()
tmp = _sum_rules(UNKNOWN_SUM_RULES, lpdf, Q)
if pdf.error_type == "replicas":
return {k: v[1:] for k,v in tmp.items()}
return tmp
return _sum_rules(UNKNOWN_SUM_RULES, lpdf, Q)

def _simple_description(d):
res = {}
Expand Down
14 changes: 7 additions & 7 deletions validphys2/src/validphys/tests/regressions/test_sum_rules_MC.csv
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
mean std min max Central value
momentum 1.0000359397024803 5.384464994542894e-07 1.000034619691424 1.0000372097117414 1.0000359463817983
uvalence 1.9997929722405798 0.00028226750040615813 1.9987658750095758 2.000123119074607 1.9997934800108916
dvalence 0.9997171906346781 0.00028320184172691307 0.9986900055519239 1.0000492249686646 0.9997173761604233
svalence 0.00024972763167990374 0.0003322524099365173 -0.00042330789669951796 0.00144823410093127 0.0002510958414509573
momentum 1.0000359402582584 5.358395010408105e-07 1.0000346238340416 1.0000372086565177 1.0000359458599606
uvalence 1.9997926747574069 0.0002809483175437137 1.998765120611357 2.0001202779127008 1.9997937994497308
dvalence 0.9997164295681845 0.00028118151759189136 0.9986902415578234 1.000046111974624 0.9997173113369415
svalence 0.00025025303862949585 0.0003303956500365186 -0.00042417491773433236 0.0014490597353980783 0.0002507254062854847
u momentum fraction 0.2555 0.0021 -1.0 -1.0 -1.0
ubar momentum fraction 3.387E-2 7.5E-4 -1.0 -1.0 -1.0
ubar momentum fraction 0.03387 0.00074 -1.0 -1.0 -1.0
d momentum fraction 0.1278 0.0021 -1.0 -1.0 -1.0
dbar momentum fraction 0.0422 0.0012 -1.0 -1.0 -1.0
s momentum fraction 0.0316 0.0020 -1.0 -1.0 -1.0
s momentum fraction 0.0316 0.002 -1.0 -1.0 -1.0
sbar momentum fraction 0.0253 0.0012 -1.0 -1.0 -1.0
cp momentum fraction 0.0286 0.0017 -1.0 -1.0 -1.0
g momentum fraction 0.4466 0.0017 -1.0 -1.0 -1.0
T3 0.79 0.23 -1.0 -1.0 -1.0
T8 4.73 0.70 -1.0 -1.0 -1.0
T8 4.73 0.7 -1.0 -1.0 -1.0
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mean std min max Central value
momentum 1.0000359343288223 3.262768320141462e-08 1.0000357928883208 1.0000360043344905 1.0000359428250625
uvalence 1.999794587352472 3.771059740749569e-05 1.9996273397296627 1.9998792759145556 1.999804641339146
dvalence 0.999719265014927 3.893093441227586e-05 0.9995458470781201 0.9998028245378152 0.9997279363904001
svalence 0.00021669265424246442 4.864440927527348e-05 3.0026081505308416e-05 0.000370776050729299 0.0002126701429466457
momentum 1.0000359346945835 3.249002390618474e-08 1.0000357949386856 1.000036007099919 1.000035943610909
uvalence 1.9997947975241677 3.774745222364767e-05 1.9996255039155293 1.9998795897064394 1.9998052948252174
dvalence 0.9997193904389039 3.913237872100671e-05 0.9995455646219639 0.9998033688013618 0.9997281952294002
svalence 0.00021668009787772745 4.881864767300481e-05 2.8212616664191614e-05 0.00037062725233145966 0.00021200815810076823
u momentum fraction 0.2554 0.00025 -1.0 -1.0 -1.0
ubar momentum fraction 0.03386 0.0001 -1.0 -1.0 -1.0
d momentum fraction 0.1277 0.00029 -1.0 -1.0 -1.0
Expand Down

0 comments on commit 21e4fea

Please sign in to comment.