Skip to content

MAINT: fix float input for number of samples#871

Merged
homosapien-lcy merged 1 commit into
mainfrom
fix_float_cast
Mar 31, 2023
Merged

MAINT: fix float input for number of samples#871
homosapien-lcy merged 1 commit into
mainfrom
fix_float_cast

Conversation

@homosapien-lcy
Copy link
Copy Markdown
Contributor

@homosapien-lcy homosapien-lcy commented Mar 31, 2023

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...

Copy link
Copy Markdown
Member

@dpinte dpinte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@homosapien-lcy homosapien-lcy merged commit fb7d8d2 into main Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants