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

Fix vispy axes labels #5565

Merged
merged 14 commits into from Feb 21, 2023
Merged

Conversation

andy-sweet
Copy link
Member

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

Description

This ensures that the vispy axes overlay labels are updated when the general data of the overlay changes. One common way this happens is as a result of a change to Dims.ndim which may occur when layers are added or removed.

I added a test to cover the bug in #5536. This relies on the same utility function I have used previously to get the vispy node scene size, so I brought that into the general test utilities.

I also added a few smaller unit tests for the vispy overlay as sanity checks before I found the actual issue.

Type of change

  • Bug-fix (non-breaking change which fixes an issue)

References

Closes #5536

@github-actions github-actions bot added qt Relates to qt tests Something related to our tests labels Feb 15, 2023
@andy-sweet
Copy link
Member Author

@brisvag : assigning you because of your recent overlay refactor work.

@psobolewskiPhD : would be great if you could also take a look and help with testing to make sure this covers all the issues you found!

@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Merging #5565 (12146b0) into main (23f45d7) will increase coverage by 1.49%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #5565      +/-   ##
==========================================
+ Coverage   87.93%   89.43%   +1.49%     
==========================================
  Files         609      611       +2     
  Lines       51238    51280      +42     
==========================================
+ Hits        45055    45860     +805     
+ Misses       6183     5420     -763     
Impacted Files Coverage Δ
napari/_qt/_tests/test_qt_viewer.py 94.72% <100.00%> (+0.11%) ⬆️
napari/_vispy/_tests/test_vispy_axes_overlay.py 100.00% <100.00%> (ø)
napari/_vispy/_tests/test_vispy_image_layer.py 100.00% <100.00%> (ø)
napari/_vispy/_tests/utils.py 100.00% <100.00%> (ø)
napari/_vispy/overlays/axes.py 100.00% <100.00%> (ø)
napari/_qt/qt_viewer.py 78.97% <0.00%> (+0.39%) ⬆️
napari/_qt/dialogs/qt_package_installer.py 81.81% <0.00%> (+0.39%) ⬆️
napari/components/viewer_model.py 96.42% <0.00%> (+0.44%) ⬆️
napari/settings/_base.py 92.89% <0.00%> (+0.47%) ⬆️
napari/utils/theme.py 94.04% <0.00%> (+0.59%) ⬆️
... and 39 more

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

@@ -17,7 +17,6 @@ def __init__(self, *, viewer, overlay, parent=None) -> None:
super().__init__(
node=Axes(), viewer=viewer, overlay=overlay, parent=parent
)
self.overlay.events.visible.connect(self._on_visible_change)
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is unrelated to the bug fix, but I picked it up along the way.

The base overlay already connects to the visible event of the overlay model. I'm not sure if the extra connection does any harm, but there's no reason for it.

Copy link
Member

@psobolewskiPhD psobolewskiPhD left a comment

Choose a reason for hiding this comment

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

I tested all the axis re-ordering, plus 3D, plus renaming.
Everything looks correct.
To me the code change makes sense 😬

Copy link
Contributor

@brisvag brisvag left a comment

Choose a reason for hiding this comment

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

I can't suggest cause it's too far from the diff, but I would then remove the call to self._on_labels_text_change() from self.reset(), since it's now duplicated by self._on_data_change()

@andy-sweet
Copy link
Member Author

Thanks for the reviews both! I'll probably merge this shortly after the weekend unless there are any objections.

I can't suggest cause it's too far from the diff, but I would then remove the call to self._on_labels_text_change() from self.reset(), since it's now duplicated by self._on_data_change()

Good catch. Done.

@psobolewskiPhD psobolewskiPhD added the ready to merge Last chance for comments! Will be merged in ~24h label Feb 17, 2023
@@ -311,7 +311,7 @@ def test_surface_normals():
faces = np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
values = np.array([1, 2, 3, 1, 2, 3, 1, 2, 3])

normals = dict(face=dict(visible=True, color='red'))
Copy link
Member Author

Choose a reason for hiding this comment

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

@brisvag : I didn't make these changes. I think this is our pre-commit linters overwriting your changes in #5501. Not sure how you bypassed them, but do you want me to add a #noqa here or just let these get changed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how that passed through, but it should be now fixed in main as well from #5575

@andy-sweet andy-sweet merged commit e669a80 into napari:main Feb 21, 2023
@andy-sweet andy-sweet deleted the fix-5536-axes-display-order branch February 21, 2023 23:33
@andy-sweet andy-sweet added the bug Something isn't working label Feb 22, 2023
@psobolewskiPhD psobolewskiPhD removed the ready to merge Last chance for comments! Will be merged in ~24h label Apr 30, 2023
@Czaki Czaki mentioned this pull request Jun 7, 2023
@andy-sweet
Copy link
Member Author

As #4907 has the 0.4.18 milestone, this should too.

@andy-sweet andy-sweet added this to the 0.4.18 milestone Jun 14, 2023
Czaki pushed a commit that referenced this pull request Jun 18, 2023
# Description
This ensures that the vispy axes overlay labels are updated when the
general data of the overlay changes. One common way this happens is as a
result of a change to `Dims.ndim` which may occur when layers are added
or removed.

I added a test to cover the bug in #5536. This relies on the same
utility function I have used previously to get the vispy node scene
size, so I brought that into the general test utilities.

I also added a few smaller unit tests for the vispy overlay as sanity
checks before I found the actual issue.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes #5536

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki pushed a commit that referenced this pull request Jun 19, 2023
# Description
This ensures that the vispy axes overlay labels are updated when the
general data of the overlay changes. One common way this happens is as a
result of a change to `Dims.ndim` which may occur when layers are added
or removed.

I added a test to cover the bug in #5536. This relies on the same
utility function I have used previously to get the vispy node scene
size, so I brought that into the general test utilities.

I also added a few smaller unit tests for the vispy overlay as sanity
checks before I found the actual issue.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes #5536

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Description
This ensures that the vispy axes overlay labels are updated when the
general data of the overlay changes. One common way this happens is as a
result of a change to `Dims.ndim` which may occur when layers are added
or removed.

I added a test to cover the bug in #5536. This relies on the same
utility function I have used previously to get the vispy node scene
size, so I brought that into the general test utilities.

I also added a few smaller unit tests for the vispy overlay as sanity
checks before I found the actual issue.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes #5536

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Description
This ensures that the vispy axes overlay labels are updated when the
general data of the overlay changes. One common way this happens is as a
result of a change to `Dims.ndim` which may occur when layers are added
or removed.

I added a test to cover the bug in #5536. This relies on the same
utility function I have used previously to get the vispy node scene
size, so I brought that into the general test utilities.

I also added a few smaller unit tests for the vispy overlay as sanity
checks before I found the actual issue.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes #5536

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki pushed a commit that referenced this pull request Jun 21, 2023
# Description
This ensures that the vispy axes overlay labels are updated when the
general data of the overlay changes. One common way this happens is as a
result of a change to `Dims.ndim` which may occur when layers are added
or removed.

I added a test to cover the bug in #5536. This relies on the same
utility function I have used previously to get the vispy node scene
size, so I brought that into the general test utilities.

I also added a few smaller unit tests for the vispy overlay as sanity
checks before I found the actual issue.

## Type of change
- [x] Bug-fix (non-breaking change which fixes an issue)

# References
Closes #5536

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working qt Relates to qt tests Something related to our tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

viewer axes point in basically random directions 😂
3 participants