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

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

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions apis/python/src/tiledbsoma/_multiscale_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,18 +508,20 @@ def coordinate_space(self, value: CoordinateSpace) -> None:
self._coord_space = value

def get_transform_from_level(self, level: Union[int, str]) -> ScaleTransform:
"""Returns the transformation from user requested level to image reference
"""Returns the transformation from user requested level to the image reference
level.

Lifecycle:
Experimental.
"""
if isinstance(level, str):
level_props = None
for val in self._levels:
if val.name == level:
level_props = val
else:
raise KeyError(f"No level with name '{level}'")
break
else:
raise KeyError("No level with name '{level}'")
else:
level_props = self._levels[level]
ref_level_props = self._schema.reference_level_properties
Expand Down Expand Up @@ -551,11 +553,13 @@ def get_transform_to_level(self, level: Union[int, str]) -> ScaleTransform:
Experimental.
"""
if isinstance(level, str):
level_props = None
for val in self._levels:
if val.name == level:
level_props = val
else:
raise KeyError(f"No level with name '{level}'")
break
else:
raise KeyError("No level with name '{level}'")
else:
level_props = self._levels[level]
ref_level_props = self._schema.reference_level_properties
Expand Down
Loading