New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type checking in Signal.sampling_rate
#533
Comments
SIgnal.sampling_rate
Signal.sampling_rate
I think we once discussed that it should be possible to have float sampling rates to be most flexible, but it definately should not be an array. We could cast it to int, if |
I was thinking more somehing like: if hasattr(sampling_rate, '__iter__'):
assert len(sampling_rate) == 1
sampling_rate = sampling_rate[0] ? |
Ah, yes - that would be needed but would not cast to integer. But it works woth float as desired:
|
Regarding casting to integer: I noticed that a pyfar.io.write_audio(pyfar.Signal(array, sampling_rate=44100.0)) will fail. I think writing to file should round to the nearest integer, cast the type and throw a warning on nonzero roundoff. What do you think? |
Can you check your pyfar version. It works for me in 0.6.3 and only thros an error if acutally having a non integer sampling rate. We fixed it a while ago following the idea you also have :) |
The
sampling_rate
kwarg in theSignal
constructor is not thoroughly typechecked or parsed which leads to errors down the line that are hard to backtrace. IMOsampling_rate
should be cast as an integer. Of course havingsampling_rate
as a 2d-array is not a great design choice but happens sometimes, e.g. when reading data from.mat
filesMWE:
The text was updated successfully, but these errors were encountered: