-
Notifications
You must be signed in to change notification settings - Fork 987
Model: Replace get_agents_of_type
method with agents_by_type
property
#2267
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
We also use `agents` and not `get_agents`, so `agents_of_type` is more consise and consistent.
Performance benchmarks:
|
I am not against making this change, but |
Fair point. At this point we can just expose the |
fce03b1
to
0da4a01
Compare
Implemented as suggested! |
If you add a test for this in test_model, its good to go as far as I am concerned. |
for more information, see https://pre-commit.ci
get_agents_of_type
to agents_of_type
get_agents_of_type
method with agents_by_type
property
Tests are added and the PR description and title are updated with some explanation and examples. Thanks for reviewing! |
…erty (projectmesa#2267) This PR replaces the Model method `get_agents_of_type()` with an `agents_by_type` property, which directly returns the dict. Instead of using: ```Python model.get_agents_of_type(Sheep) ``` You should now use: ```Python model.agents_of_type[Sheep] ``` Since we also use `agents` and not `get_agents`, it's more intuitive to directly have access to the object itself (in this case the `agents_by_type` dict). It's also is more concise and since you have full dict access, more flexible. Examples and tests are updated and an deprecation warning is added for `get_agents_of_type()`.
This PR replaces the Model method
get_agents_of_type()
with anagents_by_type
property, which directly returns the dict.Instead of using:
You should now use:
Since we also use
agents
and notget_agents
, it's more intuitive to directly have access to the object itself (in this case theagents_by_type
dict). It's also is more concise and since you have full dict access, more flexible.Examples and tests are updated and an deprecation warning is added for
get_agents_of_type()
. Example models are updated in:get_agents_of_type
method withagents_by_type
property mesa-examples#190