refactored and moved count_true from df to seq utils
This commit is contained in:
@ -38,10 +38,4 @@ def drop_col(df, name):
|
|||||||
df.drop(name, axis="columns", inplace=True)
|
df.drop(name, axis="columns", inplace=True)
|
||||||
|
|
||||||
|
|
||||||
def count_true(bdf):
|
|
||||||
good = bdf[bdf]
|
|
||||||
ngood = len(good)
|
|
||||||
return ngood
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +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 count_true, is_empty
|
||||||
from .seq import is_empty
|
|
||||||
|
|
||||||
|
|
||||||
def print_outcome(state, units):
|
def print_outcome(state, units):
|
||||||
|
@ -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):
|
def is_empty(seq):
|
||||||
return len(seq) == 0
|
return len(seq) == 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user