Skip to content

Commit acf9c50

Browse files
committed
feat: add abstract set method to AbstractAgentSet for updating agent attributes
1 parent 5f89f07 commit acf9c50

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

mesa_frames/abstract/agentset.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,35 @@ def rename(self, new_name: str, inplace: bool = True) -> Self:
492492
"""
493493
...
494494

495+
@abstractmethod
496+
def set(
497+
self,
498+
attr_names: str | Collection[str] | dict[str, Any] | None = None,
499+
values: Any | None = None,
500+
mask: AgentMask | None = None,
501+
inplace: bool = True,
502+
) -> Self:
503+
"""Update agent attributes, optionally on a masked subset.
504+
505+
Parameters
506+
----------
507+
attr_names : str | Collection[str] | dict[str, Any] | None, optional
508+
Attribute(s) to assign. When ``None``, concrete implementations may
509+
derive targets from ``values``.
510+
values : Any | None, optional
511+
Replacement value(s) aligned with ``attr_names``.
512+
mask : AgentMask | None, optional
513+
Subset selector limiting which agents are updated.
514+
inplace : bool, optional
515+
Whether to mutate in place or return an updated copy, by default True.
516+
517+
Returns
518+
-------
519+
Self
520+
The updated AgentSet (or a modified copy when ``inplace=False``).
521+
"""
522+
...
523+
495524
def __setitem__(
496525
self,
497526
key: str

0 commit comments

Comments
 (0)