77from  typing  import  Any 
88
99from  mdio  import  __version__ 
10+ from  mdio .builder .schemas .chunk_grid  import  RegularChunkGrid 
11+ from  mdio .builder .schemas .chunk_grid  import  RegularChunkShape 
1012from  mdio .builder .schemas .compressors  import  ZFP 
1113from  mdio .builder .schemas .compressors  import  Blosc 
1214from  mdio .builder .schemas .dimension  import  NamedDimension 
@@ -102,17 +104,22 @@ def add_dimension(self, name: str, size: int) -> "MDIODatasetBuilder":
102104        return  self 
103105
104106    def  push_dimension (
105-         self , dimension : NamedDimension , position : int , new_dim_chunk_size : int  =  1 ,  new_dim_size :  int   =   1 
107+         self , dimension : NamedDimension , position : int , new_dim_chunk_size : int  =  1 
106108    ) ->  "MDIODatasetBuilder" :
107109        """Pushes a dimension to all Coordiantes and Variables. 
110+ 
108111        The position argument is the domain index of the dimension to push. 
109-         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. 
112+         If a Variable is within the position domain, it will be inserted at the position 
113+         and all remaining dimensions will be shifted to the right. 
110114
111115        Args: 
112116            dimension: The dimension to push 
113117            position: The position to push the dimension to 
114118            new_dim_chunk_size: The chunk size for only the new dimension 
115119
120+         Raises: 
121+             ValueError: If the position is invalid 
122+ 
116123        Returns: 
117124            self: Returns self for method chaining 
118125        """ 
@@ -123,7 +130,6 @@ def push_dimension(
123130            msg  =  "Position is greater than the number of dimensions" 
124131            raise  ValueError (msg )
125132        if  new_dim_chunk_size  <=  0 :
126-             # TODO(BrianMichell): Do we actually need to check this, or does Pydantic handle when we call? 
127133            msg  =  "New dimension chunk size must be greater than 0" 
128134            raise  ValueError (msg )
129135
@@ -132,9 +138,6 @@ def push_dimension(
132138
133139        def  propogate_dimension (variable : Variable , position : int , new_dim_chunk_size : int ) ->  Variable :
134140            """Propogates the dimension to the variable or coordinate.""" 
135-             from  mdio .builder .schemas .chunk_grid  import  RegularChunkGrid 
136-             from  mdio .builder .schemas .chunk_grid  import  RegularChunkShape 
137- 
138141            if  len (variable .dimensions ) +  1  <=  position :
139142                # Don't do anything if the new dimension is not within the Variable's domain 
140143                return  variable 
@@ -154,12 +157,11 @@ def propogate_dimension(variable: Variable, position: int, new_dim_chunk_size: i
154157            # Update metadata with new chunk grid 
155158            new_metadata  =  variable .metadata .model_copy () if  variable .metadata  else  VariableMetadata ()
156159            new_metadata .chunk_grid  =  new_chunk_grid 
157-             ret  =  variable .model_copy (update = {"dimensions" : new_dimensions , "metadata" : new_metadata })
158-             return  ret 
160+             return  variable .model_copy (update = {"dimensions" : new_dimensions , "metadata" : new_metadata })
159161
160162        to_ignore  =  []
161163        for  v  in  self ._dimensions :
162-             to_ignore .append (v .name )
164+             to_ignore .append (v .name )   # noqa: PERF401 
163165
164166        for  i  in  range (len (self ._variables )):
165167            var  =  self ._variables [i ]
0 commit comments