-
Notifications
You must be signed in to change notification settings - Fork 17
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
pyqt scatter widget #270
base: main
Are you sure you want to change the base?
pyqt scatter widget #270
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
for more information, see https://pre-commit.ci
tests/test_scatterwidgets.py
Outdated
widget = PlotWidget(None, model) | ||
qtbot.addWidget(widget) | ||
yield widget | ||
widget.deleteLater() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you have added widget to qtbot, then you should not use deleteLater
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Czaki !
I do see the error:
E AssertionError: Some instance of QtViewer is not properly cleaned in one of previous test. For easier debug one may use --save-leaked-object-graph flag for pytest to get graph of leaked objects. If you use qtbot (from pytest-qt) to clean Qt objects after test you may need to switch to manual clean using `deleteLater()` and `qtbot.wait(50)` later.
E assert 1 == 0
when I run pytest locally (Python 3.10, Windows).
You are correct, the additional deleteLater
is unnecessary. I added it following the error message as I was getting desperate. I will remove it to avoid confusion.
Now, the minimum example to reproduce the error is:
import pytest
from napari_spatialdata._model import DataModel
from napari_spatialdata._scatterwidgets import PlotWidget
@pytest.fixture
def plot_widget(qtbot):
"""Fixture for creating a PlotWidget instance."""
model = DataModel()
widget = PlotWidget(None, model)
qtbot.addWidget(widget)
yield widget
def test_initialization(plot_widget):
"""Test initialization of PlotWidget."""
assert plot_widget is not None
def test_elementwidget(make_napari_viewer):
_ = make_napari_viewer()
assert 1 == 1
However, it's not the problem specific to this branch. If I remove all tests from test_scatterwidgets.py, the error persists:
Finally, the error is triggered only once. If I run the fake test (the code pasted in above) as test_aaa.py before any other test, the error appears in the fake test but is not triggered again by any of the original tests:
Any ideas what is going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not Idea. It is knowledge created in pain.
You may also see this error in tests executed on main.
Will try to fix this.
In general, the problem comes from previous tests that are spawning the Viewer.
in a general make_napari_viewer
fixture has few weak spots (but writing a test without using it, may lead to even more spectacular failures)
I even have opened some PR to fix it, but it is really time-consuming.
for example napari/napari#6745
Replaced with black (invisible) border when color is defined - 1acdd85
Included in 9191c7e
Suggestion in 973ebcc. Needs to be finalized. |
…tialdata into kmk-scatter-pg
for more information, see https://pre-commit.ci
…tialdata into kmk-scatter-pg
for more information, see https://pre-commit.ci
…tialdata into kmk-scatter-pg
for more information, see https://pre-commit.ci
…tialdata into kmk-scatter-pg
for more information, see https://pre-commit.ci
The notebooks start with the instruction:
However, following this instruction and starting napari (or scatter widget) will give an error |
To do:
|
TODO for me: dataset |
Description
This PR introduces a complete Scatter Widget based on PyQtGraph, intended to replace the Matplotlib-based Scatter Widget.
Rationale
Functionality
Next Steps Beyond This PR