@@ -468,13 +468,14 @@ def random(self) -> Generator:
468468 def space (self ) -> mesa_frames .abstract .space .Space | None :
469469 return self .model .space
470470
471+ @abstractmethod
471472 def rename (self , new_name : str , inplace : bool = True ) -> Self :
472473 """Rename this AgentSet.
473474
474- If this set is contained in the model's AgentSetRegistry, delegate to
475- the registry's rename implementation so that name uniqueness and
476- conflicts are handled consistently. If the set is not yet part of a
477- registry, update the local name directly .
475+ Concrete subclasses must implement the mechanics for coordinating with
476+ any containing registry and managing ``inplace`` semantics. The method
477+ should update the set's name (or return a renamed copy when
478+ ``inplace=False``) while preserving registry invariants .
478479
479480 Parameters
480481 ----------
@@ -489,31 +490,7 @@ def rename(self, new_name: str, inplace: bool = True) -> Self:
489490 Self
490491 The updated AgentSet (or a renamed copy when ``inplace=False``).
491492 """
492- obj = self ._get_obj (inplace )
493- try :
494- # If contained in registry, delegate to it so conflicts are handled
495- if self in self .model .sets : # type: ignore[operator]
496- # Preserve index to retrieve copy when not inplace
497- idx = None
498- try :
499- idx = list (self .model .sets ).index (self ) # type: ignore[arg-type]
500- except Exception :
501- idx = None
502- reg = self .model .sets .rename (self , new_name , inplace = inplace )
503- if inplace :
504- return self
505- # Non-inplace: return the corresponding set from the copied registry
506- if idx is not None :
507- return reg [idx ] # type: ignore[index]
508- # Fallback: look up by name (may be canonicalized)
509- return reg .get (new_name ) # type: ignore[return-value]
510- except Exception :
511- # If delegation cannot be resolved, fall back to local rename
512- obj ._name = new_name
513- return obj
514- # Not in a registry: local rename
515- obj ._name = new_name
516- return obj
493+ ...
517494
518495 def __setitem__ (
519496 self ,
0 commit comments