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

Minuit.interactive outside of Jupyter notebooks #771

Open
HDembinski opened this issue Jul 28, 2022 · 4 comments
Open

Minuit.interactive outside of Jupyter notebooks #771

HDembinski opened this issue Jul 28, 2022 · 4 comments

Comments

@HDembinski
Copy link
Member

Minuit.interactive can detect whether it is run inside a notebook and only then generate the UI with ipywidgets. Outside of a notebook, it could generate the UI with PyQt. This would allow one to call Minuit.interactive for debugging when some fit in a long-running script fails that does a lot of fits at once.

@CarlosMDLR
Copy link

Hello Hans, sorry for the question, but right now I am interested in generating the UI without using a notebook and using PyQt, but I can't find a way to do it after quite a few attempts. Is there a direct way to do it, or some documentation about it that I missed? Thanks for your time

@HDembinski
Copy link
Member Author

Hi Carlos, it is not possible at the moment to use the interactive mode outside of a notebook, since it is based on the ipywidgets library at the moment.

This issue exists as a reminder to implement an alternative UI based on PyQt that open in a separate window, but this does not exist yet.

@adryyan
Copy link

adryyan commented Oct 25, 2024

Hi Hans, I have tried getting this to work since this would be really helpful in my projects. I have an implementation for this in my fork that mostly works using PyQt6. When testing my implementation with the examples in the Interactive fits tutorial all of them work except when CostSum is used. This seems to be because the visualize method of CostSum calls plt.sca(ax[i]), which fails for a figure managed by FigureCanvasQTAgg. As I understand it, that some pyplot functions work with an Event Loop not managed by matplotlib is more accident than intended and when using FigureCanvasQTAgg one should really use the axes methods for plotting and avoid pyplot. So for this feature to work properly, I think all visualize methods would need to accept a matplotlib figure as a keyword argument and only use pyplot if None was provided. So before I continue to spend time on this I thought I'd ask if this would be acceptable or not wanted or if you see another solution. Thanks for all the work on this great package.

@HDembinski
Copy link
Member Author

Thank you for your effort, this sounds all sensible, why don't you make a PR then I can have a look?

I would like to avoid breaking the API, perhaps there is a workaround.

Otherwise, I am also ok with deprecating the current visualization API and make one that works on figures. Passing the objects around explicitly instead of using global variables is a better design for a library anyway.

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

No branches or pull requests

3 participants