refactored common logic for printing ignored entries
This commit is contained in:
17
commands.py
17
commands.py
@ -7,7 +7,7 @@ from utils.df import drop_col, compare_dfs, count_true
|
||||
from utils.epics import DataGetter, DataPutter
|
||||
from utils.execute import parallel, serial
|
||||
from utils.fileio import load_config, load_csv, store_csv
|
||||
from utils.printing import print_good, print_bad, print_outcome, itemize
|
||||
from utils.printing import print_good, print_bad, print_outcome, print_ignored
|
||||
from utils.seq import is_empty
|
||||
|
||||
|
||||
@ -70,24 +70,13 @@ def run_goto(clargs):
|
||||
if clargs.ignore_alarm:
|
||||
which = (df["status"] == 0) & (df["severity"] == 0)
|
||||
if not clargs.quiet:
|
||||
all_names = df.index
|
||||
ignored = all_names[~which]
|
||||
if not is_empty(ignored):
|
||||
print("ignored due to alarm state:")
|
||||
print(itemize(ignored))
|
||||
print()
|
||||
print_ignored(df, which, "alarm state")
|
||||
df = df.loc[which]
|
||||
|
||||
df = df["value"]
|
||||
|
||||
if not clargs.quiet:
|
||||
which = df.notnull()
|
||||
all_names = df.index
|
||||
ignored = all_names[~which]
|
||||
if not is_empty(ignored):
|
||||
print("ignored due to NaN value:")
|
||||
print(itemize(ignored))
|
||||
print()
|
||||
print_ignored(df, df.notnull(), "NaN value")
|
||||
df.dropna(inplace=True) #TODO: can NaN be a valid value?
|
||||
|
||||
values = df.values
|
||||
|
@ -1,4 +1,5 @@
|
||||
from .consts import SYM_NOTHING, SYM_GOOD, SYM_BAD
|
||||
from .df import count_true
|
||||
from .seq import is_empty
|
||||
|
||||
|
||||
@ -22,6 +23,14 @@ def print_bad(*args, **kwargs):
|
||||
return print(SYM_BAD, *args, **kwargs)
|
||||
|
||||
|
||||
def print_ignored(df, which, reason): #TODO: should df be the argument or df.index?
|
||||
all_names = df.index
|
||||
ignored = all_names[~which]
|
||||
if not is_empty(ignored):
|
||||
print(f"ignored due to {reason}:")
|
||||
print(itemize(ignored))
|
||||
print()
|
||||
|
||||
def itemize(iterable, bullet="•"):
|
||||
if not bullet.endswith(" "):
|
||||
bullet += " "
|
||||
|
Reference in New Issue
Block a user