From 88f1d01759458e6182df070f6918ddff6597cab7 Mon Sep 17 00:00:00 2001 From: Thomas Fillon Date: Wed, 19 Mar 2014 17:55:57 +0100 Subject: [PATCH] Level analyzer : fix Inf issue --- timeside/analyzer/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/timeside/analyzer/utils.py b/timeside/analyzer/utils.py index 6299a9c..6b03306 100644 --- a/timeside/analyzer/utils.py +++ b/timeside/analyzer/utils.py @@ -21,6 +21,8 @@ import numpy as np +MACHINE_EPSILON = np.finfo(np.float32).eps + def downsample_blocking(frames, hop_s, dtype='float32'): # downmixing to one channel if len(frames.shape) != 1: @@ -53,15 +55,12 @@ def computeModulation(serie, wLen, withLog=True): modul = np.zeros((sLen,)) w = int(wLen/2) - if withLog: - machine_epsilon = np.finfo(np.float32).eps - for i in range(w, sLen-w): d = serie[i-w:i+w] if withLog: if not (d > 0).all(): - d[d <= 0] = machine_epsilon # prevent log(0)=inf + d[d <= 0] = MACHINE_EPSILON # prevent log(0)=inf d = np.log(d) modul[i] = np.var(d) -- 2.39.5