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

[bugfix] Warn if float image data being saved to non-tiff #6884

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

psobolewskiPhD
Copy link
Member

@psobolewskiPhD psobolewskiPhD commented May 2, 2024

References and relevant issues

Closes: #6670

Description

Only a subset of file types (e.g. TIFF) support float data, so if the user passes a different extension and dtype is float, then don't try saving to invalid format and instead warn the user.
Also added a test for this condition.
Also if no extension is provided and image is 3d or float, then use .tiff instead of png.

While there are skimage and imageio functions to convert arrays to int, they make assumptions, so I think this is the best way to handle this, rather than magic'ing a conversion.

@psobolewskiPhD psobolewskiPhD added the bugfix PR with bugfix label May 2, 2024
@github-actions github-actions bot added the tests Something related to our tests label May 2, 2024
@psobolewskiPhD psobolewskiPhD added this to the 0.5.0 milestone May 2, 2024
Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.53%. Comparing base (7ebc9b4) to head (bb67146).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6884      +/-   ##
==========================================
- Coverage   92.58%   92.53%   -0.05%     
==========================================
  Files         612      612              
  Lines       55292    55315      +23     
==========================================
- Hits        51193    51187       -6     
- Misses       4099     4128      +29     

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

@Czaki
Copy link
Collaborator

Czaki commented May 2, 2024

Did you validate all extensions?
Based on documentation, the .lsm should also be able to save float.

napari/utils/io.py Outdated Show resolved Hide resolved
@Czaki Czaki added the ready to merge Last chance for comments! Will be merged in ~24h label Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix PR with bugfix ready to merge Last chance for comments! Will be merged in ~24h tests Something related to our tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[builtins writer] using .png or .jpg extension when saving single-channel image layer results in a traceback
2 participants