I have a large .wav file array (200k samples) loaded in with scipy.io.wavfile. I tried to make a histogram of the data using matplotlib.pyplot hist with auto binning. It returned the error:
ValueError: Number of samples, -72, must be non-negative.
So I decided to set the bins myself using binwidth=1000:
min_bin = np.min(data[peaks])
max_bin = np.max(data[peaks])
plt.hist(data[peaks], bins=np.arange(min_bin,max_bin, binwidth))
When I do this, it gives the error:
RuntimeWarning: overflow encountered in short_scalars
from scipy.io import wavfile
Here are the type print outs of min_bin, max_bin, data:
Type min_bin: <class 'numpy.int16'> max_bin: <class 'numpy.int16'>
min_bin: -21231 max_bin: 32444
Type data <class 'numpy.ndarray'>
The problem seems to be with np.arange which fails when I provide it the bin range from the np.max and np.min .wav array values. When I manually type the max and min integer values into np.arange it has no problem. My hypothesis is that it is some sort of addressing error when referencing the .wav array but not sure how to fix it or why it is occurring.
type(data),min_bin,max_bin,type(min_bin), andtype(max_bin)and see what the output is?