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.epics import DataGetter, DataPutter
|
||||||
from utils.execute import parallel, serial
|
from utils.execute import parallel, serial
|
||||||
from utils.fileio import load_config, load_csv, store_csv
|
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
|
from utils.seq import is_empty
|
||||||
|
|
||||||
|
|
||||||
@ -70,24 +70,13 @@ def run_goto(clargs):
|
|||||||
if clargs.ignore_alarm:
|
if clargs.ignore_alarm:
|
||||||
which = (df["status"] == 0) & (df["severity"] == 0)
|
which = (df["status"] == 0) & (df["severity"] == 0)
|
||||||
if not clargs.quiet:
|
if not clargs.quiet:
|
||||||
all_names = df.index
|
print_ignored(df, which, "alarm state")
|
||||||
ignored = all_names[~which]
|
|
||||||
if not is_empty(ignored):
|
|
||||||
print("ignored due to alarm state:")
|
|
||||||
print(itemize(ignored))
|
|
||||||
print()
|
|
||||||
df = df.loc[which]
|
df = df.loc[which]
|
||||||
|
|
||||||
df = df["value"]
|
df = df["value"]
|
||||||
|
|
||||||
if not clargs.quiet:
|
if not clargs.quiet:
|
||||||
which = df.notnull()
|
print_ignored(df, df.notnull(), "NaN value")
|
||||||
all_names = df.index
|
|
||||||
ignored = all_names[~which]
|
|
||||||
if not is_empty(ignored):
|
|
||||||
print("ignored due to NaN value:")
|
|
||||||
print(itemize(ignored))
|
|
||||||
print()
|
|
||||||
df.dropna(inplace=True) #TODO: can NaN be a valid value?
|
df.dropna(inplace=True) #TODO: can NaN be a valid value?
|
||||||
|
|
||||||
values = df.values
|
values = df.values
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from .consts import SYM_NOTHING, SYM_GOOD, SYM_BAD
|
from .consts import SYM_NOTHING, SYM_GOOD, SYM_BAD
|
||||||
|
from .df import count_true
|
||||||
from .seq import is_empty
|
from .seq import is_empty
|
||||||
|
|
||||||
|
|
||||||
@ -22,6 +23,14 @@ def print_bad(*args, **kwargs):
|
|||||||
return print(SYM_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="•"):
|
def itemize(iterable, bullet="•"):
|
||||||
if not bullet.endswith(" "):
|
if not bullet.endswith(" "):
|
||||||
bullet += " "
|
bullet += " "
|
||||||
|
Reference in New Issue
Block a user