-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
[Points, vispy] Traceback when toggling Points layer to 3D #6925
Comments
I keep running into this, so assigned myself to spend a little time thinking about how to write a test that fails on main. |
Quickly unassigning because I failed to write any test that fails on I started with some that don't require the whole viewer, but they all pass. def test_2d_to_3d_vispy_layer():
"""See https://github.com/napari/napari/issues/6925"""
layer = Points(np.zeros((4, 2)))
visual = VispyPointsLayer(layer)
dims = Dims(ndim=3, ndisplay=2)
layer._slice_dims(dims)
dims.ndisplay = 3
layer._slice_dims(dims)
def test_2d_to_3d_viewer_model():
"""See https://github.com/napari/napari/issues/6925"""
viewer = ViewerModel()
layer = viewer.add_points(np.zeros((4, 2)))
visual = VispyPointsLayer(layer)
viewer.dims.ndisplay = 3
def test_2d_to_3d_vispy_canvas():
"""See https://github.com/napari/napari/issues/6925"""
viewer = ViewerModel()
layer = viewer.add_points(np.zeros((4, 2)))
canvas = VispyCanvas(viewer, KeymapHandler())
visual = VispyPointsLayer(layer)
canvas.add_layer_visual_mapping(layer, visual)
viewer.dims.ndisplay = 3 There may be some state that could be inspected/asserted to cause a failure (e.g. looking at the width of the line visual), but that may assume too much about the implementation details. Then I tried the higher level test suggested on Zulip and even that passes: def test_points_2d_to_3d(make_napari_viewer):
"""See https://github.com/napari/napari/issues/6925"""
viewer = make_napari_viewer(ndisplay=2, show=True)
layer = viewer.add_points()
viewer.dims.ndisplay = 3 I then tried run the reproducer above as a script and even that was fine! But I can manually reproduce by clicking the 2/3D display button. |
Ah, maybe this needs Adding that does make this reproducible for me: def test_points_2d_to_3d(make_napari_viewer):
"""See https://github.com/napari/napari/issues/6925"""
viewer = make_napari_viewer(ndisplay=2, show=True)
viewer.add_points()
QApplication.processEvents()
viewer.dims.ndisplay = 3
QApplication.processEvents() |
Also note that while using a |
Interesting, the script from the OP does reproduce with no additional input for me -- fresh pull from main: eab7661 Thanks for investigating! |
I bumped into this again... I put together the suggestions from above in a PR: #7004. |
🐛 Bug Report
First reported here:
https://napari.zulipchat.com/#narrow/stream/212875-general/topic/vispy.20.22Last.20dimension.20should.20be.202.20not.203.22.20error
Creating a points layer and toggling to 3D results in a traceback:
The error is spammed, even upon return to 2D, and results in significant performance degradation.
💡 Steps to Reproduce
The following script will reproduce:
Alternately just launch napari, add points layer, and toggle to 3D.
💡 Expected Behavior
No error.
🌎 Environment
napari: 0.5.0a2.dev649+g2d2cac676
Platform: macOS-13.3.1-arm64-arm-64bit
System: MacOS 13.3.1
Python: 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:54:21) [Clang 16.0.6 ]
Qt: 6.6.1
PyQt6:
NumPy: 1.26.4
SciPy: 1.12.0
Dask: 2024.3.1
VisPy: 0.14.3.dev3
magicgui: 0.8.2
superqt: 0.6.2
in-n-out: 0.2.0
app-model: 0.2.5
npe2: 0.7.4
OpenGL:
Screens:
Optional:
Settings path:
Plugins:
💡 Additional Context
The root cause is here:
https://github.com/napari/napari/pull/6896/files#r1602264036
But the question is how are all tests passing and what can we do about it.
The text was updated successfully, but these errors were encountered: