diff --git a/benchmarks/BoltzmannWealth/boltzmann_wealth.py b/benchmarks/BoltzmannWealth/boltzmann_wealth.py index 90cb5ef1fb0..4d8eee90ff5 100644 --- a/benchmarks/BoltzmannWealth/boltzmann_wealth.py +++ b/benchmarks/BoltzmannWealth/boltzmann_wealth.py @@ -6,6 +6,7 @@ import mesa import mesa.spaces as spaces + def compute_gini(model): """Calculate gini for wealth in model. @@ -88,7 +89,7 @@ def __init__(self, model): self.wealth = 1 def give_money(self): - cellmates = [agent for agent in self.cell.agents if not agent is self] + cellmates = [agent for agent in self.cell.agents if agent is not self] if len(cellmates) > 0: other = self.random.choice(cellmates) other.wealth += 1 @@ -101,7 +102,7 @@ def step(self): self.give_money() -if __name__ == '__main__': +if __name__ == "__main__": model = BoltzmannWealth() for _ in range(10): - model.step() \ No newline at end of file + model.step() diff --git a/mesa/__init__.py b/mesa/__init__.py index 86b49d272b1..81eda89ee9f 100644 --- a/mesa/__init__.py +++ b/mesa/__init__.py @@ -6,6 +6,7 @@ import datetime import mesa.space as old_space + # import mesa.spaces as spaces import mesa.time as time from mesa.agent import Agent diff --git a/mesa/experimental/components/matplotlib.py b/mesa/experimental/components/matplotlib.py index 2ef52ea6e80..a4656cf11e7 100644 --- a/mesa/experimental/components/matplotlib.py +++ b/mesa/experimental/components/matplotlib.py @@ -10,7 +10,6 @@ import mesa - @solara.component def SpaceMatplotlib(model, agent_portrayal, dependencies: list[any] | None = None): """A component for rendering a space using Matplotlib. @@ -164,7 +163,6 @@ def portray(space): def _draw_voronoi(space, space_ax, agent_portrayal): - from mesa.spaces.voronoi import VoronoiGrid def portray(g): x = [] y = [] diff --git a/mesa/spaces/__init__.py b/mesa/spaces/__init__.py index 93c907e01bd..44ae0a5b6e7 100644 --- a/mesa/spaces/__init__.py +++ b/mesa/spaces/__init__.py @@ -1,9 +1,14 @@ -from mesa.spaces.network import Network from mesa.spaces.cell import Cell from mesa.spaces.cell_agent import CellAgent from mesa.spaces.cell_collection import CellCollection from mesa.spaces.discrete_space import DiscreteSpace -from mesa.spaces.grid import Grid, HexGrid, OrthogonalMooreGrid, OrthogonalVonNeumannGrid +from mesa.spaces.grid import ( + Grid, + HexGrid, + OrthogonalMooreGrid, + OrthogonalVonNeumannGrid, +) +from mesa.spaces.network import Network from mesa.spaces.voronoi import VoronoiGrid __all__ = [ diff --git a/mesa/spaces/cell.py b/mesa/spaces/cell.py index c68e1316445..2abb4e14ac1 100644 --- a/mesa/spaces/cell.py +++ b/mesa/spaces/cell.py @@ -123,7 +123,7 @@ def __repr__(self): # noqa # FIXME: Revisit caching strategy on methods @cache # noqa: B019 - def neighborhood(self, radius=1, include_center=False): + def neighborhood(self, radius=1, include_center=False): -> CellCollection: """Returns a list of all neighboring cells.""" return CellCollection( self._neighborhood(radius=radius, include_center=include_center),