Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve all warnings in pytest runs of examples #153

Merged
merged 7 commits into from
Aug 12, 2024

Conversation

EwoutH
Copy link
Member

@EwoutH EwoutH commented Aug 10, 2024

This PR aims to resolve all warnings in the current pytest workflow.

  • sugerscape_g1mt: Refactor using AgentSet functionality
    • Resolves 4 warnings by using the AgentSet select(), shuffle() and do() functionality.
  • charts, shape, and bank_reserves: Don't pass pos
    • Don't pass the position parameter, but just use place_agent. Resolves the duplicate position warning.
  • wolf_sheep: Replace custom scheduler with AgentSet functionality
    • This resolves all warnings outputted by this model.
    • For the model step, the behavior of the old RandomActivationByType scheduler when using step(shuffle_types=True, shuffle_agents=True) is replicated. Conceptually, it can be argued that this should be modelled differently.
    • The verbose prints are also removed.

Ready for review! I would especially hear feedback on how the AgentSet is used, and if it can be done more elegantly since these are our examples.

I would like the commits to stay separate, so I would like to merge myself using a fast-forward merge.

@EwoutH EwoutH force-pushed the resolve-all-warnings branch from 879e4ce to a5e967a Compare August 10, 2024 18:22
Resolves 4 warnings by using the AgentSet select(), shuffle() and do() functionality.

Also removes the now unused scheduler.
@EwoutH EwoutH force-pushed the resolve-all-warnings branch from a5e967a to 9146f18 Compare August 10, 2024 18:53
EwoutH added 5 commits August 10, 2024 21:03
Don't pass the position parameter, but just use place_agent. Resolves the duplicate position warning.
Don't pass the position parameter, but just use place_agent. Resolves the duplicate position warning.
This resolves all warnings outputted by this model.

For the model step, the behavior of the old RandomActivationByType scheduler when using step(shuffle_types=True, shuffle_agents=True) is replicated. Conceptually, it can be argued that this should be modelled differently.

The verbose prints are also removed.
Don't pass the position parameter, but just use place_agent. Resolves the duplicate position warning.
Uses the  -Werror option of pytest to treat warnings as errors.

See https://docs.python.org/3/using/cmdline.html#cmdoption-W
@EwoutH EwoutH marked this pull request as ready for review August 10, 2024 20:19
Use model.get_agents_of_type instead of model.agents.select() to select all agents of a certain type. It should be faster, since it's a direct dictionary call.
@EwoutH EwoutH merged commit 3e0d16f into projectmesa:main Aug 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants