Skip to content
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

Assertion error when using backend="ipywidgets" indicating to set %matplotlib widget #3236

Closed
410pfeliciano opened this issue Jul 19, 2024 · 16 comments
Labels
widgets Related to widgets module

Comments

@410pfeliciano
Copy link

If I run the following code in SI version 0.100.7, it works fine, but in versions 0.100.8 or 0.101.0rc1, it doesn't.

Here is the code running in the VS Code Jupyter Notebook on a Windows 11 computer:

%matplotlib widget
si.plot_traces(raw_rec, backend="ipywidgets", mode='line', channel_ids=raw_rec.channel_ids[:8])

This gives the following error:
---> 13 assert "ipympl" in mpl_backend, "To use the 'ipywidgets' backend, you have to set %matplotlib widget"

AssertionError: To use the 'ipywidgets' backend, you have to set %matplotlib widget

The problem is only with backend="ipywidgets", while using other options like backend="ephyviewer" works fine.

@zm711
Copy link
Collaborator

zm711 commented Jul 19, 2024

In your script did you run %matplotlib widget at the beginning?

We likely added an extra check for users to help them make sure the widgets would work. But we need to diagnose if that check is buggy :)

@zm711 zm711 added the widgets Related to widgets module label Jul 19, 2024
@zm711 zm711 changed the title backend="ipywidgets" Assertion error when using backend="ipywidgets" indicating to set %matplotlib widget Jul 19, 2024
@410pfeliciano
Copy link
Author

Yes, I use the %matplotlib widget at the beginning. In version 0.100.7, it works fine, but now I'm using the latest SI version, and in that, the same code just doesn't work.

@zm711
Copy link
Collaborator

zm711 commented Jul 19, 2024

How did you do your new install? (Also we just released 0.101.0 today if you want to upgrade to that--but there is one big API change there ).

@410pfeliciano
Copy link
Author

I did the installation using the full_spikeinterface_environment_rolling_updates.yml. I'll try to install the new release.

@zm711
Copy link
Collaborator

zm711 commented Jul 19, 2024

That should definitely work. But yeah if you're willing to install the new release with:

pip install spikeinterface[full,widgets]

specifying widgets is important to allow use of all backends.

@410pfeliciano
Copy link
Author

I installed the new version. If I run the print(f"SpikeInterface version: {si.__version__}") the Output is: SpikeInterface version: 0.101.0

But still, I have the same error. The installation was done using the full_spikeinterface_environment_windows.yml file, which has the [full, widgets] specification.

@zm711
Copy link
Collaborator

zm711 commented Jul 19, 2024

And where and how are you running your script? I have tried install from source with the widget and it worked a month ago..

@410pfeliciano
Copy link
Author

Right now, I'm running the script in VS Code Jupyter notebook. But I also ran it in Jupyter notebook alone too and had the same problem. Interestingly, I don't think the problem is Jupyter or the ipywidgets installation since I have tried some basic tutorials using the ipywidgets library and they seem to work fine.

@h-mayorquin
Copy link
Collaborator

I confirm that I can reproduce the error:

%matplotlib widget

from spikeinterface.core import generate_recording

recording = generate_recording(durations=[10.0])
from spikeinterface.widgets import plot_traces

plot_traces(recording, backend="ipywidgets", mode='line', channel_ids=recording.channel_ids[:8])

@h-mayorquin
Copy link
Collaborator

Fix in #3238

If any of you two guys want to keep the torch on that one and figure out what's going on it would be great.

The patch is working though.

@410pfeliciano
Copy link
Author

Changing %matplotlib widget to %matplotlib ipympl, as suggested by h-mayorquin, worked.

@chrishalcrow
Copy link
Collaborator

I can reproduce the error on Linux, but not on Mac. With

ipympl 0.9.4
ipywidgets 8.1.3
matplotlib 3.9.0

on both.

@JoeZiminski JoeZiminski mentioned this issue Jul 22, 2024
@taningh86
Copy link

Hi. Any solution to this issue yet? I am having the same issue with version 101 and %matplotlib ipympl also don't work. I was about to write an issue about this but found this issue on time.

@h-mayorquin
Copy link
Collaborator

Should be fixed on the main branch.

@taningh86
Copy link

@h-mayorquin my version of fixing it was removing the environment, redownloading the full_spikeinterface_environment_windows.yml file, creating the environment with that (instead of using pip), and running check_your_install.py and cleanup_for_windows.py. Then using "%matplotlib ipympl".

@h-mayorquin
Copy link
Collaborator

Mmm if you use the version from github just pip install . -U in the pertinent environment should work. But I am glad you solved your problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
widgets Related to widgets module
Projects
None yet
Development

No branches or pull requests

5 participants