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 #1056

Open
wants to merge 51 commits into
base: develop
Choose a base branch
from

Conversation

adryyan
Copy link

@adryyan adryyan commented Nov 1, 2024

Implementation of a PyQt6 widget for minuit.interactive (Issue #771 ). In order to make the plotting work properly, I changed the API for the visualize methods of the build-in cost functions so that they optionally accept matplotlib Axes objects (and for CostSums a Figure). If these arguments don't receive a value, pyplot is used. This should keep the disruption of existing code as minimal as I could manage.

src/iminuit/qtwidget.py Outdated Show resolved Hide resolved
src/iminuit/minuit.py Outdated Show resolved Hide resolved
src/iminuit/qtwidget.py Outdated Show resolved Hide resolved
src/iminuit/qtwidget.py Outdated Show resolved Hide resolved
src/iminuit/qtwidget.py Outdated Show resolved Hide resolved
src/iminuit/qtwidget.py Outdated Show resolved Hide resolved
@HDembinski
Copy link
Member

@adryyan I reviewed this PR, but you also made another where you don't change the plotting API. I prefer the other one, as expressed here.

I think we need a few iterations, but I generally appreciate your effort very much. This is a significant contribution.

@adryyan
Copy link
Author

adryyan commented Dec 6, 2024

@HDembinski Thank you for your comments; I will go through them in the next weeks.

src/iminuit/qtwidget.py Outdated Show resolved Hide resolved
tests/test_draw.py Outdated Show resolved Hide resolved
@adryyan adryyan changed the title Minuit.interactive outside of Jupyter notebooks (Changed cost visualize API) Minuit.interactive outside of Jupyter notebooks Dec 14, 2024
src/iminuit/util.py Outdated Show resolved Hide resolved
@HDembinski
Copy link
Member

HDembinski commented Dec 16, 2024

@adryyan We are coming to the finish line. Thank you for all the hard work! This is a significant addition to iminuit, and I praise your improvements to the fitting GUI and your nice unit tests. I will mimic the new GUI in a separate PR at some later point in the ipywidget widget.

The last step is to make sure that all tests pass, then we can merge this PR. I took a glance, and the failures that I see seem minor and should be easy to fix.

@HDembinski
Copy link
Member

This one looks a bit tricky https://github.com/scikit-hep/iminuit/actions/runs/12353782099/job/34473645329?pr=1056#step:9:41
INTERNALERROR> ImportError: libEGL.so.1: cannot open shared object file: No such file or directory

If you cannot figure it out, I will handle that one.

@adryyan
Copy link
Author

adryyan commented Dec 16, 2024

Thank you for all your input, I learned some new things and I feel like the code is much cleaner now.

I don't really have any experience with nox, but the problems look to me like there are issues with the installed packages and importskips. I moved all tests regarding the qtwidget into one file and put the importskip of pyqt6 before the test functions, because of the qtbot (pytest-qt). I did the same with the ipywidget tests, because the mock_ipython fixture fails if there is no IPython. But I think the actions would also need to be updated to install the necessary packages, so that the qtwidget can be tested (PyQt6, pytest-qt), but I am not sure how to do that.

@HDembinski
Copy link
Member

I don't really have any experience with nox, but the problems look to me like there are issues with the installed packages

Yes, it should not have anything to do with nox. This looks like the image is missing a dependency. In fact, that error occurs in the doc build as well, but does not cause a failure:
https://github.com/scikit-hep/iminuit/actions/runs/12360486430/job/34524584092?pr=1056#step:8:80

The Test / X tests only check the basic functionality, that's why they do not expose this issue.

@HDembinski
Copy link
Member

HDembinski commented Dec 19, 2024

Fixing the CI issue turns out to be difficult. I am getting segfaults when the PyQt code is executed, presumably because there is a mismatch between the versions of libraries that Qt links to at run-time and those which the PyQt Python package was build against. I found this nice install qt action, which should avoid exactly that issue, but it does not work. It is always annoying when the error only appears on CI, that makes debugging difficult.

One way to fix this is to install all the required packages with conda/mamba, then all the external libs should be consistent with the libs used to build the python package.

Another idea is to port this all to PySide, which is now officially supported by Qt. Although it is not clear whether that would avoid the issue.

@adryyan
Copy link
Author

adryyan commented Dec 19, 2024

Changing from PyQt6 to PySide6 is quite easy in the code, so it doesn't hurt to try (a817bc9).

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