@@ -3836,7 +3836,10 @@ def collapsed(self, coords, aggregator, **kwargs):
38363836 """
38373837 # Update weights kwargs (if necessary) to handle different types of
38383838 # weights
3839- (kwargs , weights_units ) = _Weights .get_updated_kwargs (kwargs , self )
3839+ weights_info = None
3840+ if kwargs .get ("weights" ) is not None :
3841+ weights_info = _Weights (kwargs ["weights" ], self )
3842+ kwargs ["weights" ] = weights_info .array
38403843
38413844 # Convert any coordinate names to coordinates
38423845 coords = self ._as_list_of_coords (coords )
@@ -3984,7 +3987,7 @@ def collapsed(self, coords, aggregator, **kwargs):
39843987 collapsed_cube ,
39853988 coords ,
39863989 axis = collapse_axis ,
3987- _weights_units = weights_units ,
3990+ _weights_units = getattr ( weights_info , "units" , None ) ,
39883991 ** kwargs ,
39893992 )
39903993 result = aggregator .post_process (
@@ -4078,7 +4081,10 @@ def aggregated_by(
40784081 """
40794082 # Update weights kwargs (if necessary) to handle different types of
40804083 # weights
4081- (kwargs , weights_units ) = _Weights .get_updated_kwargs (kwargs , self )
4084+ weights_info = None
4085+ if kwargs .get ("weights" ) is not None :
4086+ weights_info = _Weights (kwargs ["weights" ], self )
4087+ kwargs ["weights" ] = weights_info .array
40824088
40834089 groupby_coords = []
40844090 dimension_to_groupby = None
@@ -4275,7 +4281,7 @@ def aggregated_by(
42754281 aggregateby_cube ,
42764282 groupby_coords ,
42774283 aggregate = True ,
4278- _weights_units = weights_units ,
4284+ _weights_units = getattr ( weights_info , "units" , None ) ,
42794285 ** kwargs ,
42804286 )
42814287 # Replace the appropriate coordinates within the aggregate-by cube.
@@ -4415,7 +4421,10 @@ def rolling_window(self, coord, aggregator, window, **kwargs):
44154421 """
44164422 # Update weights kwargs (if necessary) to handle different types of
44174423 # weights
4418- (kwargs , weights_units ) = _Weights .get_updated_kwargs (kwargs , self )
4424+ weights_info = None
4425+ if kwargs .get ("weights" ) is not None :
4426+ weights_info = _Weights (kwargs ["weights" ], self )
4427+ kwargs ["weights" ] = weights_info .array
44194428
44204429 coord = self ._as_list_of_coords (coord )[0 ]
44214430
@@ -4502,7 +4511,7 @@ def rolling_window(self, coord, aggregator, window, **kwargs):
45024511 new_cube ,
45034512 [coord ],
45044513 action = "with a rolling window of length %s over" % window ,
4505- _weights_units = weights_units ,
4514+ _weights_units = getattr ( weights_info , "units" , None ) ,
45064515 ** kwargs ,
45074516 )
45084517 # and perform the data transformation, generating weights first if
0 commit comments