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 handling of units and axis_labels in add_image #7089

Merged
merged 2 commits into from
Jul 16, 2024

Conversation

brisvag
Copy link
Contributor

@brisvag brisvag commented Jul 12, 2024

Description

The new axis_labels and units arguments for layers are iterables; they need to be added to the iterable arguments to avoid problems with the channel splitting in the case of an image stack.

Currently, this fails:

import napari
import numpy as np
v = napari.Viewer()
a = np.random.rand(2, 2)
v.add_image(a, axis_labels=('x', 'y'))

with:

TypeError: Received sequence for argument 'axis_labels', did you mean to specify a 'channel_axis'?

Copy link

codecov bot commented Jul 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.86%. Comparing base (157b144) to head (b63d3df).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7089      +/-   ##
==========================================
- Coverage   92.95%   92.86%   -0.10%     
==========================================
  Files         618      618              
  Lines       56486    56490       +4     
==========================================
- Hits        52509    52457      -52     
- Misses       3977     4033      +56     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Czaki Czaki added this to the 0.5.1 milestone Jul 12, 2024
@Czaki Czaki added the bugfix PR with bugfix label Jul 12, 2024
@jni
Copy link
Member

jni commented Jul 13, 2024

Maybe add a test? 😉

@github-actions github-actions bot added the tests Something related to our tests label Jul 15, 2024
@brisvag
Copy link
Contributor Author

brisvag commented Jul 15, 2024

Added a simple test that takes the output of _get_state() to create a new layer. Will fail if any of the arguments are poorly treated in that is_sequence function.

@Czaki Czaki added the ready to merge Last chance for comments! Will be merged in ~24h label Jul 15, 2024
Copy link
Contributor

@GenevieveBuckley GenevieveBuckley left a comment

Choose a reason for hiding this comment

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

Works great, nice fix @brisvag

@GenevieveBuckley GenevieveBuckley merged commit 5e685a2 into napari:main Jul 16, 2024
38 checks passed
@github-actions github-actions bot removed the ready to merge Last chance for comments! Will be merged in ~24h label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR with bugfix tests Something related to our tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants