Modify Space Drawers to use explicit Cell positions#3323
Conversation
2d75d06 to
f798f39
Compare
f798f39 to
645f793
Compare
|
Do we need fallback if we are removing |
|
Performance benchmarks:
|
No, I'll try to open a pr later this week for removing mesa.space. |
|
In #3337, I removed mesa.space. Can you update this PR accordingly. Code wise, I have given it a quick check already and did not see anything strange. |
|
All Set! I have updated the PR |
quaquel
left a comment
There was a problem hiding this comment.
Have you visually checked everything?
Looks fine to me otherwise.
Yes, On |
|
Remaining examples are working fine. |
|
There is more weird stuff going on with networks. If you reset the model, the visual style is also changed. Initially, it is a grey circle with a white center. On reset, it becomes a grey center. @Sahil-Chhoker, any thoughts? |
|
I have started to dig into this. The problem is in |
This doesn't seem to solve the issue |
|
If I do elif isinstance(self.space, Network):
# no need to map network node IDs to positions
mapped_arguments["loc"] = arguments["loc"].astype(float)the issue is gone |
|
Ok, My bad. I was running it on |
|
I have opened a PR to fix it. That can be merged after this one. |
quaquel
left a comment
There was a problem hiding this comment.
a last couple of questions, but after that, this seems good to go.


This PR updates the
mesa.visualization.space_drawersto leverage the newly introducedcell.positionattribute for the DiscreteSpace API.Previously, Space Drawers had to independently guess or mathematically recalculate the physical geometry of spaces (e.g., computing hex offsets or running network layout algorithms).
Key Changes
HexSpaceDrawerviz_xmin,viz_xmax,viz_ymin, andviz_ymaxare now dynamically calculated directly from the absolute minimum and maximum values of the cells' physical positions._get_hexmeshnow anchors hexagons exactly atcell.positioninstead of relying on a hardcoded row/col math algorithm._get_hexmeshfromlist[tuple[float, float]]to the factually accuratelist[list[tuple[float, float]]](a list of hexagons).NetworkSpaceDrawercell._position). This prevents the visualizer from redundantly executing heavy NetworkX layout algorithms (likenx.spring_layout) if the model has already calculated them during setup.VoronoiSpaceDrawercell.positioninstead of centroid coordinatesNote: Full backward compatibility has been maintained for
mesa.spaceobjects via fallbacks