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

Move mesa.experimental_cell to mesa.discrete_space #2610

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

quaquel
Copy link
Member

@quaquel quaquel commented Jan 10, 2025

As part of the stabilization of cell spaces, this PR moves everything to mesa.discrete_space. I have kept the mesa.experimental.cell_space, which should continue to function but will issue a deprecation warning.

I updated all tests and all examples that use cell spaces.

@tpike3
Copy link
Member

tpike3 commented Jan 11, 2025

I think the deprecation warning needs to be updated, from the build failure in test examples it is saying

"DeprecationWarning: you are importing from mesa.discrete_space, all cell spaces have been moved to mesa.discrete_space"

shouldn't this be "DeprecationWarning: you are importing from mesa.experimental.cell_space, all cell spaces have been moved to mesa.discrete_space"

Copy link
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quaquel Thanks for doing this!

Before you merge could you update the tests or the pyproject so the build isn't failing with the deprecation warning.

@EwoutH
Copy link
Member

EwoutH commented Jan 12, 2025

I would like to take a good look at namespaces, also to make it futureproof for other network spaces etc. Hopefully I can do that Tuesday.

Also we should split off a 3.1 maintenance branch before merging.

@quaquel
Copy link
Member Author

quaquel commented Jan 12, 2025

Before you merge could you update the tests or the pyproject so the build isn't failing with the deprecation warning.

Yes, this is very much on my list of things to do before merging.

I would like to take a good look at namespaces, also to make it futureproof for other network spaces etc

No idea what you mean with this. There is a network in the current mesa.spaces, and one in mesa.experimental.cell_spaces. These both assume that the network structure is fixed. So there is room for a changing network space (although I am not sure about a real use case for it).

@quaquel
Copy link
Member Author

quaquel commented Jan 12, 2025

build/examples is now failing on the deprecation warning as intended. This is running mesa-examples. All other tests and builds work fine.

@tpike3
Copy link
Member

tpike3 commented Jan 13, 2025

build/examples is now failing on the deprecation warning as intended. This is running mesa-examples. All other tests and builds work fine.

If possible, can you ensure the build passes, just because it may hide other issues, pytest should be able to handle it either

in the test_examples with something like

def test_with_deprecation():
    with pytest.warns(DeprecationWarning, match="you are importing from mesa.experimental.cell_space, all cell spaces have been moved to mesa.discrete_space"):
        warnings.warn("you are importing from mesa.experimental.cell_space, all cell spaces have been moved to mesa.discrete_space", DeprecationWarning)

or globally in the pyproject.toml

[pytest]
filterwarnings =
    ignore:.*some specific warning message.*:DeprecationWarning

@EwoutH
Copy link
Member

EwoutH commented Jan 18, 2025

Currently the from mesa.discrete_space.discrete_space import DiscreteSpace feels a bit weird. Maybe it makes more sense to keep the top level space named cell_space, it would make it very distinct and the concept of cell is intuitive.

Otherwise, if you, Tom and other @projectmesa/maintainers agree, don't let me block you.

@quaquel
Copy link
Member Author

quaquel commented Jan 18, 2025

you can actually use a shorter import: from mesa.discrete_space import DiscreteSpace.

@quaquel
Copy link
Member Author

quaquel commented Jan 19, 2025

@tpike3: the failing action is the one that runs mesa-examples. So, this build runs all examples in the mesa-examples repo. All tests on the mesa repo itself, including the examples that ship with mesa itself, pass without problems. Our most complete integration test is erroring and only because of a deprecation warning.

About the only thing I see that can be done to get the built to pass is to explicitly ignore the deprecation warnings by changing this line in built_lint.yml. Let me know what you think about that.

@tpike3
Copy link
Member

tpike3 commented Jan 19, 2025

@tpike3: the failing action is the one that runs mesa-examples. So, this build runs all examples in the mesa-examples repo. All tests on the mesa repo itself, including the examples that ship with mesa itself, pass without problems. Our most complete integration test is erroring and only because of a deprecation warning.

About the only thing I see that can be done to get the built to pass is to explicitly ignore the deprecation warnings by changing this line in built_lint.yml. Let me know what you think about that.

Works for me, thanks!

@quaquel
Copy link
Member Author

quaquel commented Jan 19, 2025

Ok, all tests now pass correctly so this is ready to be merged. However, I want to hold of for a short while still. (1). we need to first create a 3.1 maintenance branch, and (2) I ran into a small bug in hexgrid. I know how to resolve the bug, which is due to mixing up (row, column) indexing in hexgrid and (x, y) coordinates when visualizing.

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.

3 participants