single-cell-data / TileDB-SOMA

Python and R SOMA APIs using TileDB’s cloud-native format. Ideal for single-cell data at any scale.
https://tiledbsoma.readthedocs.io
MIT License
87 stars 25 forks source link

[python] Fix retrieval of named levels from a MultiscaleImage #3119

Closed aaronwolen closed 4 days ago

aaronwolen commented 4 days ago

Before this PR:

scene.img["tissue"].get_transform_to_level(0)
## <somacore.coordinates.ScaleTransform at 0x17701b390>

scene.img["tissue"].get_transform_to_level("hires")
## KeyError                                  Traceback (most recent call last)
## Cell In[325], line 1
## ----> 1 scene.img[image_name].get_transform_to_level("hires")
## 
## File ~/Library/CloudStorage/Dropbox-TileDB/Aaron Wolen/customers/czi/TileDB-SOMA2/apis/python/src/tiledbsoma/_multiscale_image.py:551, in MultiscaleImage.get_transform_to_level(self, level)
##     549             level_props = val
##     550         else:
## --> 551             raise KeyError("No level with name '{level}'")
##     552 else:
##     553     level_props = self._levels[level]
## 
## KeyError: "No level with name '{level}'"

With this PR:

scene.img["tissue"].get_transform_to_level(0)
## <somacore.coordinates.ScaleTransform object at 0x16f7667d0>

scene.img["tissue"].get_transform_to_level("hires")
## <somacore.coordinates.ScaleTransform object at 0x16f8189d0>
codecov[bot] commented 4 days ago

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 86.49%. Comparing base (c2a34e5) to head (a42737f). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3119 +/- ## =========================================== + Coverage 63.31% 86.49% +23.18% =========================================== Files 113 47 -66 Lines 14331 4924 -9407 Branches 855 0 -855 =========================================== - Hits 9073 4259 -4814 + Misses 5050 665 -4385 + Partials 208 0 -208 ``` | [Flag](https://app.codecov.io/gh/single-cell-data/TileDB-SOMA/pull/3119/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=single-cell-data) | Coverage Δ | | |---|---|---| | [libtiledbsoma](https://app.codecov.io/gh/single-cell-data/TileDB-SOMA/pull/3119/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=single-cell-data) | `?` | | | [python](https://app.codecov.io/gh/single-cell-data/TileDB-SOMA/pull/3119/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=single-cell-data) | `86.49% <0.00%> (-0.08%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=single-cell-data#carryforward-flags-in-the-pull-request-comment) to find out more. | [Components](https://app.codecov.io/gh/single-cell-data/TileDB-SOMA/pull/3119/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=single-cell-data) | Coverage Δ | | |---|---|---| | [python_api](https://app.codecov.io/gh/single-cell-data/TileDB-SOMA/pull/3119/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=single-cell-data) | `86.49% <0.00%> (-0.08%)` | :arrow_down: | | [libtiledbsoma](https://app.codecov.io/gh/single-cell-data/TileDB-SOMA/pull/3119/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=single-cell-data) | `∅ <ø> (∅)` | |