Skip to content

Commit 4c8030f

Browse files
authored
Merge pull request #231 from NNPDF/fix-operator-card-db
Fix operator cards db layout in ekomark
2 parents ca63b0e + 946d392 commit 4c8030f

File tree

2 files changed

+62
-53
lines changed

2 files changed

+62
-53
lines changed

src/ekomark/data/db.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
"""
2-
Database tables
3-
"""
1+
"""Database tables."""
42

53
from banana.data.db import Base
64
from sqlalchemy import Boolean, Column, Integer, Text
75

86

97
class Operator(Base): # pylint: disable=too-few-public-methods
10-
"""
11-
Operator cards table
12-
"""
8+
"""Operator cards table."""
139

1410
__tablename__ = "operators"
1511

1612
interpolation_is_log = Column(Text)
1713
interpolation_polynomial_degree = Column(Integer)
18-
xgrid = Column(Text)
14+
interpolation_xgrid = Column(Text)
1915
debug_skip_non_singlet = Column(Boolean)
2016
debug_skip_singlet = Column(Boolean)
2117
ev_op_max_order = Column(Integer)

src/ekomark/navigator/navigator.py

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""EKO implementation of navigator."""
12
import os
23
import webbrowser
34

@@ -19,30 +20,30 @@
1920

2021

2122
class NavigatorApp(bnav.navigator.NavigatorApp):
22-
"""
23-
Navigator base class holding all elementry operations.
23+
"""Navigator base class holding all elementry operations.
2424
2525
Parameters
2626
----------
27-
cfg : dict
28-
banana configuration
29-
mode : str
30-
mode identifier
27+
cfg : dict
28+
banana configuration
29+
mode : str
30+
mode identifier
31+
3132
"""
3233

3334
myname = "eko"
3435
table_objects = table_objects
3536

3637
def fill_theories(self, theo, obj):
37-
"""
38-
Collect important information of the theory record.
38+
"""Collect important information of the theory record.
3939
4040
Parameters
4141
----------
42-
theo : dict
43-
database record
44-
obj : dict
45-
to be updated pandas record
42+
theo : dict
43+
database record
44+
obj : dict
45+
to be updated pandas record
46+
4647
"""
4748
for f in [
4849
"PTO",
@@ -60,17 +61,17 @@ def fill_theories(self, theo, obj):
6061
obj["mtThr"] = theo["mt"] * theo["ktThr"]
6162

6263
def fill_operators(self, op, obj):
63-
"""
64-
Collect important information of the operator record.
64+
"""Collect important information of the operator record.
6565
6666
Parameters
6767
----------
68-
op : dict
69-
database record
70-
obj : dict
71-
to be updated pandas record
68+
op : dict
69+
database record
70+
obj : dict
71+
to be updated pandas record
72+
7273
"""
73-
xgrid = op["xgrid"]
74+
xgrid = op["interpolation_xgrid"]
7475
obj["xgrid"] = (
7576
f"{len(xgrid)}pts: "
7677
+ f"{'log' if op['interpolation_is_log'] else 'x'}"
@@ -85,15 +86,15 @@ def fill_operators(self, op, obj):
8586
obj["time"] = op["time_like"]
8687

8788
def fill_cache(self, cac, obj):
88-
"""
89-
Collect important information of the cache record.
89+
"""Collect important information of the cache record.
9090
9191
Parameters
9292
----------
93-
cac : dict
94-
database record
95-
obj : dict
96-
to be updated pandas record
93+
cac : dict
94+
database record
95+
obj : dict
96+
to be updated pandas record
97+
9798
"""
9899
vals = cac["result"]["values"]
99100
q2s = list(vals.keys())
@@ -109,15 +110,15 @@ def fill_cache(self, cac, obj):
109110
obj[f] = cac[f]
110111

111112
def fill_logs(self, lg, obj):
112-
"""
113-
Collect important information of the log record.
113+
"""Collect important information of the log record.
114114
115115
Parameters
116116
----------
117-
lg : dict
118-
database record
119-
obj : dict
120-
to be updated pandas record
117+
lg : dict
118+
database record
119+
obj : dict
120+
to be updated pandas record
121+
121122
"""
122123
q2s = lg["log"].q2s
123124
crash = lg.get("_crash", None)
@@ -132,13 +133,13 @@ def fill_logs(self, lg, obj):
132133
obj[f] = lg[f]
133134

134135
def check_log(self, doc_hash, perc_thr=1, abs_thr=1e-6):
135-
"""
136-
Check if the log passed the default assertions
136+
"""Check if the log passed the default assertions.
137137
138138
Parameters
139139
----------
140-
doc_hash : hash
141-
log hash
140+
doc_hash : hash
141+
log hash
142+
142143
"""
143144
dfds = self.log_as_dfd(doc_hash)
144145
log = self.get(bnav.l, doc_hash)
@@ -153,13 +154,13 @@ def check_log(self, doc_hash, perc_thr=1, abs_thr=1e-6):
153154
print(op, row, sep="\n", end="\n\n")
154155

155156
def plot_pdfs(self, doc_hash):
156-
"""
157-
Plots all PDFs at the final scale.
157+
"""Plot all PDFs at the final scale.
158158
159159
Parameters
160160
----------
161-
doc_hash : hash
162-
log hash
161+
doc_hash : hash
162+
log hash
163+
163164
"""
164165
log = self.get(bnav.l, doc_hash)
165166
dfd = log["log"]
@@ -175,7 +176,6 @@ def plot_pdfs(self, doc_hash):
175176
print(f"Writing pdf plots to {path}")
176177

177178
with PdfPages(path) as pp:
178-
179179
# print setup
180180
theory = self.get(bnav.t, log["t_hash"][: self.hash_len])
181181
ops = self.get(bnav.o, log["o_hash"][: self.hash_len])
@@ -200,13 +200,13 @@ def plot_pdfs(self, doc_hash):
200200
return path
201201

202202
def display_pdfs(self, doc_hash):
203-
"""
204-
Display PDF generated by ekomark.navigator.navigator.plot_pdfs
203+
"""Display PDF generated by ekomark.navigator.navigator.plot_pdfs.
205204
206205
Parameters
207206
----------
208-
doc_hash : hash
209-
log hash
207+
doc_hash : hash
208+
log hash
209+
210210
"""
211211
log = self.get(bnav.l, doc_hash)
212212
directory = (
@@ -230,11 +230,23 @@ def display_pdfs(self, doc_hash):
230230

231231
@staticmethod
232232
def is_valid_physical_object(name):
233+
"""Check if is actual name.
234+
235+
Parameters
236+
----------
237+
name : str
238+
name
239+
240+
Returns
241+
-------
242+
bool :
243+
is actual name?
244+
245+
"""
233246
return name in br.evol_basis or name in br.flavor_basis_names
234247

235248
def compare_external(self, dfd1, dfd2):
236-
"""
237-
Compare two results in the cache.
249+
"""Compare two results in the cache.
238250
239251
It's taking two results from external benchmarks and compare them in a
240252
single table.
@@ -245,6 +257,7 @@ def compare_external(self, dfd1, dfd2):
245257
if hash the doc_hash of the cache to be loaded
246258
dfd2 : dict or hash
247259
if hash the doc_hash of the cache to be loaded
260+
248261
"""
249262
# load json documents
250263
id1, cache1 = self.load_dfd(dfd1, self.cache_as_dfd)

0 commit comments

Comments
 (0)