dejavu icon indicating copy to clipboard operation
dejavu copied to clipboard

divide by zero warning

Open soroosh-rz opened this issue 6 years ago • 2 comments

Hello,

I am testing and executing the code in Fedora, however during the fingerprinting of mp3 directory I receive these warnings:

dejavu/fingerprint.py:82: RuntimeWarning: divide by zero encountered in log10 arr2D = 10 * np.log10(arr2D)

I wonder if these warnings are normal and if they have impact on the finals results? I'd be grateful if you could help me to find out my answer.

Thanks,

soroosh-rz avatar Mar 05 '18 22:03 soroosh-rz

Not sure how numpy's log10 function works here, but you probably have 0's in your spectrogram. no worries

CwbhX avatar Jul 31 '18 12:07 CwbhX

yes, that's right the problem is in the fingerprint.py file, on fingerprint method, it applies np.log10 over an array with some 0s, that causes to return -np.Inf on those cases (and thus the warning you're seeing). If you check the code the developer later replace those negative np.Inf with 0s. A more fancy solution to avoid that would be to replace those lines with:

# Apply log transform since specgram() returns linear array. 0s are excluded to avoid np warning.
arr2D = 10 * np.log10(arr2D, out=np.zeros_like(arr2D), where=(arr2D != 0))

mauricio-repetto avatar Sep 20 '19 19:09 mauricio-repetto