File tree 1 file changed +6
-13
lines changed
1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -106,23 +106,16 @@ def agent_types(self) -> list[type]:
106
106
"""Return a list of all unique agent types registered with the model."""
107
107
return list (self ._agents_by_type .keys ())
108
108
109
- def agents_of_type (self , agenttype : type [Agent ]) -> AgentSet :
110
- """Retrieves an AgentSet containing all agents of the specified type.
111
-
112
- Args:
113
- agenttype: The type of agent to retrieve.
114
-
115
- Raises:
116
- KeyError: If agenttype does not exist
117
-
118
-
119
- """
120
- return self ._agents_by_type [agenttype ]
109
+ @property
110
+ def agents_by_type (self ) -> dict [type [Agent ], AgentSet ]:
111
+ """A dictionary where the keys are agent types and the values are the corresponding AgentSets."""
112
+ return self ._agents_by_type
121
113
122
114
def get_agents_of_type (self , agenttype : type [Agent ]) -> AgentSet :
123
115
"""Deprecated: Retrieves an AgentSet containing all agents of the specified type."""
124
116
warnings .warn (
125
- "get_agents_of_type is deprecated, please use agents_of_type instead." ,
117
+ f"Model.get_agents_of_type() is deprecated, please replace get_agents_of_type({ agenttype } )"
118
+ f"with the property agents_by_type[{ agenttype } ]." ,
126
119
DeprecationWarning ,
127
120
stacklevel = 2 ,
128
121
)
You can’t perform that action at this time.
0 commit comments