adafruit / Adafruit_Learning_System_Guides

Programs and scripts to display "inline" in Adafruit Learning System guides
MIT License
994 stars 769 forks source link

ulab.scipy.signal import spectrogram stopped working with 8.0.0-beta.4 #2335

Closed somenice closed 8 months ago

somenice commented 1 year ago

CircuitPython version

Adafruit CircuitPython 8.0.0-beta.4 on 2022-10-30; Adafruit QT Py RP2040 with rp2040

Code/REPL

from ulab.scipy.signal import spectrogram

Behavior

ImportError: can't import name spectrogram

Description

Had working example of this tutorial: https://learn.adafruit.com/mini-led-matrix-audio-visualizer Stopped working after latest update.

Additional information

From the repl >>> help(ulab.scipy.signal) shows only sosfilt function. None for scipy.signal.spectrogram

jepler commented 1 year ago

I've transferred this report to Learn.

ulab 5.0 (first in CircuitPython 8) made an incompatible change, so that spectrogram is in ulab.utils rather than ulab.scipy.signal. The following examples need to be updated, and the guide text needs to be reviewed in case it should be updated as well:

EyeLights_Audio_Spectrum/EyeLights_Audio_Spectrum_CircuitPython/code.py:from ulab.scipy.signal import spectrogram
Feather_Sense_Audio_Visualizer_13x9_RGB_LED_Matrix/audio_spectrum_lightshow/code.py:from ulab.scipy.signal import spectrogram
Feather_Sense_Audio_Visualizer_13x9_RGB_LED_Matrix/waterfall_visualizer/code.py:from ulab.scipy.signal import spectrogram
Ukulele/code.py:from ulab.scipy.signal import spectrogram
ulab_Crunch_Numbers_Fast/waterfall/code.py:from ulab.scipy.signal import spectrogram

During the transitional period, where it's reasonable to accomodate using 7.3 and 8.x, I think the code should read

try:
    from ulab.utils import spectrogram
except ImportError:
    from ulab.scipy.signal import spectrogram

then the example should be tested using both 7.3 and 8.0.

jepler commented 1 year ago

@kattni is this one that eva could potentially take on?

somenice commented 1 year ago

Thank you for the quick fix @jepler I can confirm from ulab.utils import spectrogram works as intended.

ps. note the typo in code above except ImpotError: thanks again

jepler commented 1 year ago

Thanks both for testing and noticing the typo!

kattni commented 1 year ago

@evaherrada Please add this to your list. You need to update the ulab utils import to the following:

try:
    from ulab.utils import spectrogram
except ImportError:
    from ulab.scipy.signal import spectrogram

If you have any questions, please reach out to @jepler in this thread. Thank you!