@@ -101,7 +101,9 @@ def add_dimension(self, name: str, size: int) -> "MDIODatasetBuilder":
101101 self ._state = _BuilderState .HAS_DIMENSIONS
102102 return self
103103
104- def push_dimension (self , dimension : NamedDimension , position : int , new_dim_chunk_size : int = 1 , new_dim_size : int = 1 ) -> "MDIODatasetBuilder" :
104+ def push_dimension (
105+ self , dimension : NamedDimension , position : int , new_dim_chunk_size : int = 1 , new_dim_size : int = 1
106+ ) -> "MDIODatasetBuilder" :
105107 """Pushes a dimension to all Coordiantes and Variables.
106108 The position argument is the domain index of the dimension to push.
107109 If a Variable is within the position domain, it will be inserted at the position and all remaining dimensions will be shifted to the right.
@@ -130,23 +132,25 @@ def push_dimension(self, dimension: NamedDimension, position: int, new_dim_chunk
130132
131133 def propogate_dimension (variable : Variable , position : int , new_dim_chunk_size : int ) -> Variable :
132134 """Propogates the dimension to the variable or coordinate."""
133- from mdio .builder .schemas .chunk_grid import RegularChunkGrid , RegularChunkShape
135+ from mdio .builder .schemas .chunk_grid import RegularChunkGrid
136+ from mdio .builder .schemas .chunk_grid import RegularChunkShape
137+
134138 if len (variable .dimensions ) + 1 <= position :
135139 # Don't do anything if the new dimension is not within the Variable's domain
136140 return variable
137141 new_dimensions = variable .dimensions [:position ] + [dimension ] + variable .dimensions [position :]
138-
142+
139143 # Get current chunk shape from metadata
140144 current_chunk_shape = (1 ,) * len (variable .dimensions ) # Default fallback
141145 if variable .metadata is not None and variable .metadata .chunk_grid is not None :
142146 current_chunk_shape = variable .metadata .chunk_grid .configuration .chunk_shape
143-
147+
144148 # Insert new chunk size at the correct position
145149 new_chunk_shape = current_chunk_shape [:position ] + (new_dim_chunk_size ,) + current_chunk_shape [position :]
146-
150+
147151 # Create new chunk grid configuration
148152 new_chunk_grid = RegularChunkGrid (configuration = RegularChunkShape (chunk_shape = new_chunk_shape ))
149-
153+
150154 # Update metadata with new chunk grid
151155 new_metadata = variable .metadata .model_copy () if variable .metadata else VariableMetadata ()
152156 new_metadata .chunk_grid = new_chunk_grid
0 commit comments