dejavu
dejavu copied to clipboard
divide by zero warning
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,
Not sure how numpy's log10 function works here, but you probably have 0's in your spectrogram. no worries
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))