Skip to content

Comments

Add axis_labels and units, refactor to using properties in nImage#45

Merged
TimMonko merged 3 commits intondev-kit:mainfrom
TimMonko:feat/nimage-properties
Jan 31, 2026
Merged

Add axis_labels and units, refactor to using properties in nImage#45
TimMonko merged 3 commits intondev-kit:mainfrom
TimMonko:feat/nimage-properties

Conversation

@TimMonko
Copy link
Member

@TimMonko TimMonko commented Jan 31, 2026

Description

I've been long unhappy with the cruft I set up in nImage, and I've long been wanting to convert to a cleaner API.
I think I finally am starting to grok @property where it can be used effectively as a function to "get" an object, while still accessing it like an attribute. This is a step towards cleaning up the API :)

Second, I've also been wanting to incorporate more axis metadata, and bioio has recently added both units and dimension_properties. So, this PR uses properties to also add:

  1. axis_labels
  2. units

In addition to scale. Speaking of scale, this now contains a bugfix for layers that contain time, woops! the tuple wasn't long enough because it only inherited from physical pixel sizes, and not time. Gah

I have also made the decision to break the public API here I have renamed attributes from napari_scale to layer_scale because it was causing some overlap and redundancy. Now it's more clear that this is getting something for a layer object and not, e.g. a viewer.

Going forward I promise not to break these objects like this again. Please open an issue if this is a problem, but I know there is not yet much use of this so I can easily make a backwards compatible patch if needed.

@codecov
Copy link

codecov bot commented Jan 31, 2026

Codecov Report

❌ Patch coverage is 95.58824% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/ndevio/nimage.py 95.52% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@TimMonko TimMonko merged commit 88dd815 into ndev-kit:main Jan 31, 2026
12 checks passed
TimMonko added a commit that referenced this pull request Feb 3, 2026
# Description

Follow-up to #45 

This fixes an accidentally broken property and then continues to
refactor nImage. Largely, this is meant to super clean up the API. It

1. Refactors out many methods to a new module `_layer_utils.py`
2. Cleans up the `get_layer_data_tuples` code path, especially for RGB
3. Cleans up typing throughout
4. Removes dead code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant