Skip to content

Commit

Permalink
refactor: global shut "Mean of empty slice" warning when .median() of…
Browse files Browse the repository at this point in the history
… all NA
  • Loading branch information
chanshing committed Jun 11, 2024
1 parent 130ec33 commit eca3c46
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/stepcount/stepcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from stepcount import __model_version__
from stepcount import __model_md5__

warnings.filterwarnings('ignore', message='Mean of empty slice') # shut .median() warning when all-NaN



def main():

Expand Down Expand Up @@ -456,9 +459,7 @@ def _max(x, min_wear=None, dt=None):
def _median(x, min_wear=None, dt=None):
if not _is_enough(x, min_wear, dt):
return np.nan
with warnings.catch_warnings():
warnings.filterwarnings('ignore', message='Mean of empty slice')
return x.median()
return x.median()

def _percentile_at(x, ps=(5, 25, 50, 75, 95), min_wear=None, dt=None):
percentiles = {f'p{p:02}_at': np.nan for p in ps}
Expand Down

0 comments on commit eca3c46

Please sign in to comment.