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

Move layer editable change from slicing to controls #5546

Merged
merged 3 commits into from
Feb 20, 2023

Conversation

andy-sweet
Copy link
Member

@andy-sweet andy-sweet commented Feb 9, 2023

Description

This moves some side-effects of changing the display dimensionality from Layer._slice_dims to the layer controls. This means the side-effects typically only occur in the full viewer.

Alternatively, we could consider connecting Dims.ndisplay to this side-effect in ViewerModel, so that a more standard headless napari would see the same behavior.

A further alternative is to not have the side-effect on Layer.editable and instead just update the layer control editable buttons' enabled state directly.

Motivation

This is partially motivated by the async slicing/loading work (#4795) because it makes Layer._slice_dims almost identical to Layer.refresh, except that _slice_dims may still sometimes return early. More specifically, it would allow us to simplify the sync default/fallback option when integrating async slicing.

One upside is that the tests exercise some public API (even if it's part of napari's Qt/GUI code), rather than calling a private method as their main action.

@andy-sweet andy-sweet changed the title Move layer editable change from slicing to controls [WIP] Move layer editable change from slicing to controls Feb 9, 2023
@github-actions github-actions bot added qt Relates to qt tests Something related to our tests labels Feb 9, 2023
@@ -148,7 +148,7 @@ def _add(self, event):
"""
layer = event.value
controls = create_qt_layer_controls(layer)
controls.ndisplay = 3
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why I set this to 3 specifically in #5491...

@andy-sweet andy-sweet marked this pull request as ready for review February 15, 2023 17:45
@andy-sweet andy-sweet requested a review from jni February 15, 2023 17:46
@andy-sweet
Copy link
Member Author

@jni : we discussed this in the recent architecture working group meeting, so I assigned you to review. Let me know if you want someone else to take a look instead or in addition.

@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Merging #5546 (cf14dbc) into main (d3ab430) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5546      +/-   ##
==========================================
+ Coverage   89.36%   89.37%   +0.01%     
==========================================
  Files         608      608              
  Lines       51098    51109      +11     
==========================================
+ Hits        45663    45679      +16     
+ Misses       5435     5430       -5     
Impacted Files Coverage Δ
napari/layers/base/base.py 91.74% <ø> (-0.02%) ⬇️
napari/layers/points/_tests/test_points.py 100.00% <ø> (ø)
...qt/layer_controls/_tests/test_qt_layer_controls.py 100.00% <100.00%> (ø)
.../_qt/layer_controls/qt_layer_controls_container.py 100.00% <100.00%> (ø)
napari/_qt/layer_controls/qt_points_controls.py 92.94% <100.00%> (+0.09%) ⬆️
napari/_qt/layer_controls/qt_shapes_controls.py 88.88% <100.00%> (+0.15%) ⬆️
napari/_qt/dialogs/qt_package_installer.py 81.81% <0.00%> (+0.39%) ⬆️
napari/utils/theme.py 94.04% <0.00%> (+0.59%) ⬆️
napari/utils/info.py 85.10% <0.00%> (+1.06%) ⬆️
napari/_qt/__init__.py 56.66% <0.00%> (+6.66%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@andy-sweet andy-sweet changed the title [WIP] Move layer editable change from slicing to controls Move layer editable change from slicing to controls Feb 15, 2023
Copy link
Member

@jni jni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a lot of sense to me, thanks @andy-sweet!

@jni jni added the ready to merge Last chance for comments! Will be merged in ~24h label Feb 17, 2023
@andy-sweet
Copy link
Member Author

Thanks for the quick review! I'll merge this shortly after the weekend unless there are any objections.

@brisvag brisvag merged commit def704c into napari:main Feb 20, 2023
@brisvag brisvag removed the ready to merge Last chance for comments! Will be merged in ~24h label Feb 20, 2023
@andy-sweet andy-sweet deleted the remove-reset-editable branch February 21, 2023 14:46
@Czaki Czaki mentioned this pull request Jun 7, 2023
@andy-sweet andy-sweet added this to the 0.5.0 milestone Jun 14, 2023
@Czaki Czaki modified the milestones: 0.5.0, 0.4.18 Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qt Relates to qt tests Something related to our tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants