You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in stop_sifting() the line: "sx = np.abs(envmoy) / amp" sometimes causes a divide by zero error.
also, I notice that right above this line (currently 376) there are some try/except checks for the return values of self.mean_and_amplitude(), but ONLY for two very specific errors. seems there should be an unconditional "except" too.
what's the right fix here?
-- jdm
The text was updated successfully, but these errors were encountered:
to get this to not crash, I wrapped that line with a try/except - after telling Numpy to raise Python errors (otherwise it doesn't).
as I'm not intimately familiar with the code, I just did that (below), which should be reviewed and rewritten to be cleaner, e.g., making it part of the preceding try/except, or even better, clean up the entire function.
Here's my hack of emd.py - again, I just wanted it to not crash, not make it pretty. Except for the print, where I use F-expressions, it should be fine for both Python 2.x and 3.x, but I haven't verified it on 2.x.
377 ###
378 # JDM added try/catch to keep from true_divide error when dividing by amp
379 ###
380 import sys
381 old_err = np.seterr(all='raise') # make Numpy errors raise Python exceptions, or we won't see them
382 try:
383 sx = np.abs(envmoy) / amp
384 except:
385 print(f"WARNING: stop_sifting() caught exception dividing by amp, type {sys.exc_info()[0]}, value={sys.exc_info()[1]}")
386 print(f"envmoy={envmoy}\namp={amp}")
387 return 1, np.zeros((len(m)))
388 finally:
389 np.seterr(**old_err) # restore
390 ## end jdm part
in stop_sifting() the line: "sx = np.abs(envmoy) / amp" sometimes causes a divide by zero error.
also, I notice that right above this line (currently 376) there are some try/except checks for the return values of self.mean_and_amplitude(), but ONLY for two very specific errors. seems there should be an unconditional "except" too.
what's the right fix here?
-- jdm
The text was updated successfully, but these errors were encountered: