@@ -298,9 +298,10 @@ def _(d, mapper, rebuilt, sregistry):
298298 tkns = tuple (tkn ._rebuild (name = sregistry .make_name (prefix = tkn .name ))
299299 for tkn in d .thickness )
300300 kwargs = {'thickness' : tkns }
301- fkwargs = {}
301+ fkwargs = {'function' : None , 'halo' : None , 'padding' : None }
302302
303303 idim0 = d .implicit_dimension
304+ idim1 = None
304305 if idim0 is not None :
305306 if idim0 in rebuilt :
306307 idim1 = rebuilt [idim0 ]
@@ -309,34 +310,34 @@ def _(d, mapper, rebuilt, sregistry):
309310 rebuilt [idim0 ] = idim1 = idim0 ._rebuild (name = iname )
310311
311312 kwargs ['implicit_dimension' ] = idim1
312- fkwargs ['dimensions' ] = (idim1 ,) + d .functions .dimensions [1 :]
313313
314- if d .functions in rebuilt :
315- functions = rebuilt [d .functions ]
316- else :
317- # Increment every instance of this name after the first encountered
318- fname = sregistry .make_name (prefix = d .functions .name , increment_first = False )
319- # Warn the user if name has been changed, since this will affect overrides
320- if fname != d .functions .name :
321- fkwargs ['name' ] = fname
322- warning (
323- f"{ str (d .functions )} <{ id (d .functions )} > renamed as '{ fname } '. "
324- "Consider assigning a unique name to {d.functions.name}."
325- )
326-
327- fkwargs .update ({'function' : None ,
328- 'halo' : None ,
329- 'padding' : None })
330-
331- # Data in MultiSubDimension function may not have been touched at this point,
332- # in which case do not use an allocator, as there is nothing to allocate, and
333- # doing so will petrify the `_data` attribute as None.
334- if d .functions ._data is not None :
335- fkwargs .update ({'allocator' : DataReference (d .functions ._data )})
336-
337- rebuilt [d .functions ] = functions = d .functions ._rebuild (** fkwargs )
338-
339- kwargs ['functions' ] = functions
314+ functions = []
315+ for f in as_tuple (d .functions ):
316+ if f in rebuilt :
317+ functions .append (rebuilt [f ])
318+ else :
319+ # Increment every instance of this name after the first encountered
320+ fname = sregistry .make_name (prefix = f .name , increment_first = False )
321+ # Warn the user if name has been changed, since this will affect overrides
322+ if fname != f .name :
323+ fkwargs ['name' ] = fname
324+ warning (
325+ f"{ str (f )} <{ id (f )} > renamed as '{ fname } '. "
326+ f"Consider assigning a unique name to { f .name } ."
327+ )
328+
329+ if idim1 is not None :
330+ fkwargs ['dimensions' ] = (idim1 ,) + f .dimensions [1 :]
331+ # Data in MultiSubDimension function may not have been touched at this point,
332+ # in which case do not use an allocator, as there is nothing to allocate, and
333+ # doing so will petrify the `_data` attribute as None.
334+ if f ._data is not None :
335+ fkwargs .update ({'allocator' : DataReference (f ._data )})
336+
337+ rebuilt [f ] = f ._rebuild (** fkwargs )
338+ functions .append (rebuilt [f ])
339+
340+ kwargs ['functions' ] = tuple (functions )
340341
341342 mapper [d ] = d ._rebuild (** kwargs )
342343 mapper .update (zip (d .thickness , tkns , strict = True ))
0 commit comments