-
Notifications
You must be signed in to change notification settings - Fork 877
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
Cleanup and restructure basic example models #2365
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This looks largely fine to me. However, can you run ruff on the examples? The docstring is not allways up to date. In places its missing (e.g., boidflockers app.py) or arguments are in the signature but not the docstring. It can be done as part of this PR or in a follow up PR, but it would be good to ensure that also the documentation is exemplary. |
I installed the packages with The other approach is to add mesa explicitly to your Python path: import sys
import os
# Add the 'mesa/mesa' directory to the Python path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../mesa")))
I have to figure out what’s the best general approach here, either the pip, path or something else. Then I will document that for all examples. Thoughts on this are welcome! |
@Corvince I now mostly use matplotlib for space drawings. Would you generally recommend that, or are there any/all cases in which Altair might be a better fit? |
Another this: I used |
For now I think this is fine, because we are not there yet, but long term I think altair will be the better choice, as it opens up so much more possibilities. Altair is aware of its data, so it allows things like clicking or hovering on specific agents to trigger some actions, like implemented in mesa-interactive. Thinking about it, its not hard to bring that functionality to mesa, I see if I can submit a PR for it soon. It also allows tooltips with additional information. Currently the biggest downside is the performance. But Altair ultimatively translates into vega and vega allows dynamically updating the data. So there are some hackish ways to achieve this and maybe this can at some time be done without hacks. And maybe there are more obvious things to increase the performance, I havent looked closely yet. |
I dont think I understand how these 2 things relate to each other. I also don't understand why ruff does not run for the examples automatically? Shouldn't this be part of our CI? Oh and in general: Great work @EwoutH ! I like the improved visualizations. Haven't looked closely at the code yet. |
Thanks for the context on Altair! I will actively support and facilitate any work on that.
Maybe I understood the questions wrong. You can just run the models through either the visualisation (
It didn't in mesa-examples, and I didn't want everything to break in the original PR. I disabled it purposely here in |
Ah, yes I think you did. @quaquel asked if you could run ruff on the examples, not how you could run the examples. But I agree that it should be done in a separate PR, otherwise its too hard to distinguish the ruff changes from normal changes. |
Lol totally missed the word “ruff” in that sentence. Merging, so we can continue with other stuff from our list. |
Update the visualisation with sliders sliders for coloured boids.
- Restructure into agents.py and model.py - Make compute_gini a Model function
- Rename cell.py to agents.py - Flatten structure - Remove unneeded viz
- Split of SchellingAgent in agents.py - Remove run_ascii.py (not supported anymore) - Clean up files
Still used the old BatchRunner, this commit updates it to use batch_run and cleans it up
Fix the sliders in the SolaraViz app.py to use the new API.
- VirusAgent in agents.py - Flatten structure - Remove old visualisation code
10a2ef5
to
d7a3834
Compare
This PR updates the basic example models to:
agents.py
file.This PR is structured in 9 commits, here are the specific updates per model/commit:
Boid Flockers and Virus on Network also got improved visualisation, which now looks like: