Skip to content

Commit

Permalink
Fix operator cards db layout
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhekhorn committed Mar 24, 2023
1 parent 73e438e commit 946d392
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 53 deletions.
10 changes: 3 additions & 7 deletions src/ekomark/data/db.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
"""
Database tables
"""
"""Database tables."""

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


class Operator(Base): # pylint: disable=too-few-public-methods
"""
Operator cards table
"""
"""Operator cards table."""

__tablename__ = "operators"

interpolation_is_log = Column(Text)
interpolation_polynomial_degree = Column(Integer)
xgrid = Column(Text)
interpolation_xgrid = Column(Text)
debug_skip_non_singlet = Column(Boolean)
debug_skip_singlet = Column(Boolean)
ev_op_max_order = Column(Integer)
Expand Down
105 changes: 59 additions & 46 deletions src/ekomark/navigator/navigator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""EKO implementation of navigator."""
import os
import webbrowser

Expand All @@ -19,30 +20,30 @@


class NavigatorApp(bnav.navigator.NavigatorApp):
"""
Navigator base class holding all elementry operations.
"""Navigator base class holding all elementry operations.
Parameters
----------
cfg : dict
banana configuration
mode : str
mode identifier
cfg : dict
banana configuration
mode : str
mode identifier
"""

myname = "eko"
table_objects = table_objects

def fill_theories(self, theo, obj):
"""
Collect important information of the theory record.
"""Collect important information of the theory record.
Parameters
----------
theo : dict
database record
obj : dict
to be updated pandas record
theo : dict
database record
obj : dict
to be updated pandas record
"""
for f in [
"PTO",
Expand All @@ -60,17 +61,17 @@ def fill_theories(self, theo, obj):
obj["mtThr"] = theo["mt"] * theo["ktThr"]

def fill_operators(self, op, obj):
"""
Collect important information of the operator record.
"""Collect important information of the operator record.
Parameters
----------
op : dict
database record
obj : dict
to be updated pandas record
op : dict
database record
obj : dict
to be updated pandas record
"""
xgrid = op["xgrid"]
xgrid = op["interpolation_xgrid"]
obj["xgrid"] = (
f"{len(xgrid)}pts: "
+ f"{'log' if op['interpolation_is_log'] else 'x'}"
Expand All @@ -85,15 +86,15 @@ def fill_operators(self, op, obj):
obj["time"] = op["time_like"]

def fill_cache(self, cac, obj):
"""
Collect important information of the cache record.
"""Collect important information of the cache record.
Parameters
----------
cac : dict
database record
obj : dict
to be updated pandas record
cac : dict
database record
obj : dict
to be updated pandas record
"""
vals = cac["result"]["values"]
q2s = list(vals.keys())
Expand All @@ -109,15 +110,15 @@ def fill_cache(self, cac, obj):
obj[f] = cac[f]

def fill_logs(self, lg, obj):
"""
Collect important information of the log record.
"""Collect important information of the log record.
Parameters
----------
lg : dict
database record
obj : dict
to be updated pandas record
lg : dict
database record
obj : dict
to be updated pandas record
"""
q2s = lg["log"].q2s
crash = lg.get("_crash", None)
Expand All @@ -132,13 +133,13 @@ def fill_logs(self, lg, obj):
obj[f] = lg[f]

def check_log(self, doc_hash, perc_thr=1, abs_thr=1e-6):
"""
Check if the log passed the default assertions
"""Check if the log passed the default assertions.
Parameters
----------
doc_hash : hash
log hash
doc_hash : hash
log hash
"""
dfds = self.log_as_dfd(doc_hash)
log = self.get(bnav.l, doc_hash)
Expand All @@ -153,13 +154,13 @@ def check_log(self, doc_hash, perc_thr=1, abs_thr=1e-6):
print(op, row, sep="\n", end="\n\n")

def plot_pdfs(self, doc_hash):
"""
Plots all PDFs at the final scale.
"""Plot all PDFs at the final scale.
Parameters
----------
doc_hash : hash
log hash
doc_hash : hash
log hash
"""
log = self.get(bnav.l, doc_hash)
dfd = log["log"]
Expand All @@ -175,7 +176,6 @@ def plot_pdfs(self, doc_hash):
print(f"Writing pdf plots to {path}")

with PdfPages(path) as pp:

# print setup
theory = self.get(bnav.t, log["t_hash"][: self.hash_len])
ops = self.get(bnav.o, log["o_hash"][: self.hash_len])
Expand All @@ -200,13 +200,13 @@ def plot_pdfs(self, doc_hash):
return path

def display_pdfs(self, doc_hash):
"""
Display PDF generated by ekomark.navigator.navigator.plot_pdfs
"""Display PDF generated by ekomark.navigator.navigator.plot_pdfs.
Parameters
----------
doc_hash : hash
log hash
doc_hash : hash
log hash
"""
log = self.get(bnav.l, doc_hash)
directory = (
Expand All @@ -230,11 +230,23 @@ def display_pdfs(self, doc_hash):

@staticmethod
def is_valid_physical_object(name):
"""Check if is actual name.
Parameters
----------
name : str
name
Returns
-------
bool :
is actual name?
"""
return name in br.evol_basis or name in br.flavor_basis_names

def compare_external(self, dfd1, dfd2):
"""
Compare two results in the cache.
"""Compare two results in the cache.
It's taking two results from external benchmarks and compare them in a
single table.
Expand All @@ -245,6 +257,7 @@ def compare_external(self, dfd1, dfd2):
if hash the doc_hash of the cache to be loaded
dfd2 : dict or hash
if hash the doc_hash of the cache to be loaded
"""
# load json documents
id1, cache1 = self.load_dfd(dfd1, self.cache_as_dfd)
Expand Down

0 comments on commit 946d392

Please sign in to comment.