diff --git a/utils/df.py b/utils/df.py index 1c2ed09..0031d76 100644 --- a/utils/df.py +++ b/utils/df.py @@ -38,10 +38,4 @@ def drop_col(df, name): df.drop(name, axis="columns", inplace=True) -def count_true(bdf): - good = bdf[bdf] - ngood = len(good) - return ngood - - diff --git a/utils/printing.py b/utils/printing.py index 27464c5..82f2753 100644 --- a/utils/printing.py +++ b/utils/printing.py @@ -1,6 +1,5 @@ from .consts import SYM_NOTHING, SYM_GOOD, SYM_BAD -from .df import count_true -from .seq import is_empty +from .seq import count_true, is_empty def print_outcome(state, units): diff --git a/utils/seq.py b/utils/seq.py index f8df990..c42cd43 100644 --- a/utils/seq.py +++ b/utils/seq.py @@ -1,5 +1,13 @@ +import numpy as np + + +def count_true(seq): + bools = np.asanyarray(seq, dtype=bool) + return np.count_nonzero(bools) + def is_empty(seq): return len(seq) == 0 +