MAINT: fix float input for number of samples #871
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A float is inputed to linspace as sample number which causes error, this pr fixes it
closes issue #869
Though a new error happens:
(py311) cyliu@aus552cyliu chaco % python3.11 examples/demo/advanced/spec_waterfall.py
traitsui.version 8.0.0.dev0
pyface.version 7.4.4
2023-03-31 10:35:54.804 Python[3049:51857] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/2z/kylzj9s92y71cxscmljmpqrh0000gt/T/org.python.python.savedState
/Users/cyliu/Documents/3.11_test/chaco/examples/demo/advanced/spec_waterfall.py:178: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
audio_data = fromstring(stream.read(NUM_SAMPLES), dtype=short)
Traceback (most recent call last):
File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/pyface/timer/i_timer.py", line 200, in perform
self._perform()
File "/Users/cyliu/.venvs/py311/lib/python3.11/site-packages/pyface/timer/i_timer.py", line 299, in _perform
self.callback(*self.args, **self.kwargs)
File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/advanced/spec_waterfall.py", line 187, in onTimer
spectrum, time = get_audio_data()
^^^^^^^^^^^^^^^^
File "/Users/cyliu/Documents/3.11_test/chaco/examples/demo/advanced/spec_waterfall.py", line 181, in get_audio_data
return (abs(fft(normalized_data))[: NUM_SAMPLES // 2], normalized_data)
^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable
Investigation...