-
Notifications
You must be signed in to change notification settings - Fork 923
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
Add support for drawing discrete grids #2386
Conversation
for more information, see https://pre-commit.ci
Performance benchmarks:
|
Uninstall your current mesa, |
Thanks! This gave me the idea for a slightly different approach: insert the correct version of mesa into sys.path at the top. Based on this, I can confirm that this code works as intended. Let me know what else would be needed to complete this PR since its my first contribution to the visualization side of things. |
That's the other obvious way to go, both have their advantages based on what your working on. @Corvince I'm also quite new to this stack, could you please review this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is very fine and a good first step. I pre-approve this, just please also add OrthogonalVonNeumann
@@ -11,7 +11,7 @@ | |||
from matplotlib.figure import Figure | |||
|
|||
import mesa | |||
from mesa.experimental.cell_space import VoronoiGrid | |||
from mesa.experimental.cell_space import OrthogonalMooreGrid, VoronoiGrid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also work for OrthogonalVonNeumannGrid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I'll fix that! Just need to figure out how to capture this in the match case statement.
I guess it even will work for hexgrids (although we might want to visualize these a bit differently with offsets for every odd row.
@@ -52,16 +52,20 @@ def SpaceMatplotlib( | |||
if space is None: | |||
space = getattr(model, "space", None) | |||
|
|||
if isinstance(space, mesa.space._Grid): | |||
_draw_grid(space, space_ax, agent_portrayal, propertylayer_portrayal, model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @quaquel, I understand that this is already merged. May I ask whether it is intentional to remove the call to _draw_grid()
here? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I made a mistake. I'll put in a PR to fix this asap.
Thanks for the post-merge review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and fixed via #2398
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks!
One improvement for this function would be to use the |
I looked at that and I could not use it because that method is hard coded to only work with |
Add support for drawing experimental Grid Spaces (i.e. HexGrid, OrthogonalMooreGrid, OrthogonalVonNeumannGrid).
Closes #2377. This code needs further refinement (e.g., duplication of agent potrayal code from voroinoi grid, offsets for hexgrids, and adding experiment NetworkGrids).