From 946d392e9b8918f0018ae07cdffa7bc16c154386 Mon Sep 17 00:00:00 2001 From: Felix Hekhorn Date: Fri, 24 Mar 2023 15:43:16 +0100 Subject: [PATCH] Fix operator cards db layout --- src/ekomark/data/db.py | 10 +-- src/ekomark/navigator/navigator.py | 105 ++++++++++++++++------------- 2 files changed, 62 insertions(+), 53 deletions(-) diff --git a/src/ekomark/data/db.py b/src/ekomark/data/db.py index a9fe0fd9f..6aa3beab6 100644 --- a/src/ekomark/data/db.py +++ b/src/ekomark/data/db.py @@ -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) diff --git a/src/ekomark/navigator/navigator.py b/src/ekomark/navigator/navigator.py index 137ecca64..11d8fe141 100644 --- a/src/ekomark/navigator/navigator.py +++ b/src/ekomark/navigator/navigator.py @@ -1,3 +1,4 @@ +"""EKO implementation of navigator.""" import os import webbrowser @@ -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", @@ -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'}" @@ -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()) @@ -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) @@ -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) @@ -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"] @@ -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]) @@ -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 = ( @@ -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. @@ -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)