Supress warning: RuntimeWarning: Mean of empty slice (#271)
* Supress warning: RuntimeWarning: Mean of empty slice Signed-off-by: Jose Santos <josantos@login1.hpcfund> * Move import to top Signed-off-by: Jose Santos <josantos@login1.hpcfund> * Specify type of RuntimeWarning in catcher. Safer approach Signed-off-by: colramos-amd <colramos@amd.com> * Comply to formatting Signed-off-by: colramos-amd <colramos@amd.com> --------- Signed-off-by: Jose Santos <josantos@login1.hpcfund> Signed-off-by: colramos-amd <colramos@amd.com> Co-authored-by: Jose Santos <josantos@login1.hpcfund> Co-authored-by: colramos-amd <colramos@amd.com>
This commit is contained in:
+4
-1
@@ -33,6 +33,7 @@ from utils import schema
|
||||
from utils.utils import error
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import warnings
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Internal global definitions
|
||||
@@ -142,7 +143,9 @@ def to_median(a):
|
||||
if a is None:
|
||||
return None
|
||||
elif isinstance(a, pd.core.series.Series):
|
||||
return a.median()
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("ignore", message="Mean of empty slice")
|
||||
return a.median()
|
||||
else:
|
||||
raise Exception("to_median: unsupported type.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user