3535if TYPE_CHECKING :
3636 from collections .abc import Sequence
3737 from ome_zarr_models .v04 .multiscales import Multiscale as MultiscaleV04
38- from ome_zarr_models ._v06 .coordinate_transforms import CoordinateSystem as CoordinateSystemV06
38+ from ome_zarr_models ._v06 .coordinate_transforms import (
39+ CoordinateSystem as CoordinateSystemV06 ,
40+ )
41+ from ome_zarr_models ._v06 .multiscales import Multiscale as MultiscaleV06
3942
4043
4144__all__ = ["Dataset" , "Multiscale" ]
@@ -56,7 +59,9 @@ class Multiscale(BaseAttrs):
5659 name : JsonValue | None = None
5760 type : JsonValue = None
5861
59- def to_version (self , version : Literal ["0.4" , "0.6" ], ** kwargs ) -> MultiscaleV04 :
62+ def to_version (
63+ self , version : Literal ["0.4" , "0.6" ], ** kwargs : Any
64+ ) -> MultiscaleV04 | MultiscaleV06 :
6065 """
6166 Convert this Multiscale metadata to the specified version.
6267
@@ -72,10 +77,9 @@ def to_version(self, version: Literal["0.4", "0.6"], **kwargs) -> MultiscaleV04:
7277
7378 def _to_v06 (
7479 self ,
75- multiscale_v05 : Multiscale ,
7680 intrinsic_system_name : str ,
7781 top_level_system : CoordinateSystemV06 | None = None ,
78- ) -> Self :
82+ ) -> MultiscaleV06 :
7983 """
8084 Convert a OME-Zarr 0.5 multiscales to OME-Zarr 0.6.
8185
@@ -90,9 +94,16 @@ def _to_v06(
9094 multiscales transforms into. If the top-level transform is present, must be
9195 given. Otherwise, will not be used.
9296 """
93- from ome_zarr_models ._v06 .multiscales import _v05_transform_to_v06
94- from ome_zarr_models ._v06 .coordinate_transforms import CoordinateSystem , Axis
95- new_ms = self (
97+ from ome_zarr_models ._v06 .multiscales import (
98+ Multiscale as MultiscaleV06 ,
99+ _v05_transform_to_v06 ,
100+ )
101+ from ome_zarr_models ._v06 .coordinate_transforms import (
102+ CoordinateSystem ,
103+ Axis ,
104+ )
105+
106+ new_ms = MultiscaleV06 (
96107 datasets = tuple (
97108 Dataset (
98109 path = ds .path ,
@@ -105,22 +116,22 @@ def _to_v06(
105116 ),
106117 ),
107118 )
108- for ds in multiscale_v05 .datasets
119+ for ds in self .datasets
109120 ),
110121 coordinateSystems = (
111122 CoordinateSystem (
112123 name = intrinsic_system_name ,
113124 axes = tuple (
114125 Axis (name = ax .name , type = ax .type , unit = ax .unit )
115- for ax in multiscale_v05 .axes
126+ for ax in self .axes
116127 ),
117128 ),
118129 ),
119- metadata = multiscale_v05 .metadata ,
120- name = multiscale_v05 .name ,
121- type = multiscale_v05 .type ,
130+ metadata = self .metadata ,
131+ name = self .name ,
132+ type = self .type ,
122133 )
123- if multiscale_v05 .coordinateTransformations is not None :
134+ if self .coordinateTransformations is not None :
124135 if top_level_system is None :
125136 raise ValueError (
126137 "top_level_system must be provided because a top-level "
@@ -130,7 +141,7 @@ def _to_v06(
130141 update = {
131142 "coordinateTransformations" : (
132143 _v05_transform_to_v06 (
133- multiscale_v05 .coordinateTransformations
144+ self .coordinateTransformations
134145 ).model_copy (
135146 update = {
136147 "input" : intrinsic_system_name ,
0 commit comments