Skip to content

Remove PropertyLayer usage from mesa-examples#334

Merged
quaquel merged 9 commits intomesa:mainfrom
codebreaker32:main
Mar 2, 2026
Merged

Remove PropertyLayer usage from mesa-examples#334
quaquel merged 9 commits intomesa:mainfrom
codebreaker32:main

Conversation

@codebreaker32
Copy link
Contributor

@codebreaker32 codebreaker32 commented Feb 20, 2026

This PR removes the PropertyLayer from termites, hex_ant, conways_game_of_life_fast and reflects the usage of updated API introduced in #3340

Termites:

# before
self.wood_chips_layer = PropertyLayer("woodcell", (width, height), default_value=False, dtype=bool)
self.wood_chips_layer.data = self.rng.choice(...)
self.grid.add_property_layer(self.wood_chips_layer)

# after
wood_chips = self.rng.choice([True, False], size=(width, height), p=[...])
self.grid.add_property_layer("woodcell", wood_chips)

Game of Life:

# before
self.cell_layer = PropertyLayer("cells", (width, height), default_value=False, dtype=bool)
self.cell_layer.data = np.random.choice(...)

# after
self.cell_layer_data = np.random.choice([True, False], size=(width, height), p=[...])

Hex Ant:

# before
layer = getattr(self.grid, layer_name)
np_layer = layer.data

# after
np_layer = self.grid.property_layers[layer_name]

Part of the broader PropertyLayer removal tracked in #3340

@quaquel
Copy link
Member

quaquel commented Feb 23, 2026

I guess this needs updating in light of how the PR has changed?

@codebreaker32
Copy link
Contributor Author

I guess this needs updating in light of how the PR has changed?

No, its fine. I have already updated it yesterday

@quaquel
Copy link
Member

quaquel commented Feb 23, 2026

ok, so its just the description that still reflects the original API.

@codebreaker32
Copy link
Contributor Author

Done. Updated the description as well.

@quaquel
Copy link
Member

quaquel commented Feb 28, 2026

This looks fine. The build still fails because of the game of life example. How do you want to proceed with that one?

@codebreaker32 codebreaker32 changed the title Remove PropertyLayer from Termites model Remove PropertyLayer usage from mesa-examples Mar 1, 2026
@codebreaker32
Copy link
Contributor Author

The build still fails because of the game of life example. How do you want to proceed with that one?

I modified it to use numpy arrays directly instead of property layers. Also, updated other examples.

@quaquel
Copy link
Member

quaquel commented Mar 2, 2026

It still seem to error on the termite model? I am fine with taking a look myself as well if needed.

@codebreaker32
Copy link
Contributor Author

It still seem to error on the termite model? I am fine with taking a look myself as well if needed.

It might be that pre tests are running on an older version seeing the errors, You are most welcome to take a look as well.

@quaquel
Copy link
Member

quaquel commented Mar 2, 2026

you are right, that test is against mesa 3.5, rather than against main.

@quaquel quaquel merged commit 2ba3032 into mesa:main Mar 2, 2026
3 of 4 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