Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and quaquel committed Sep 18, 2024
1 parent 06b0998 commit 6e53612
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
7 changes: 4 additions & 3 deletions benchmarks/BoltzmannWealth/boltzmann_wealth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import mesa
import mesa.spaces as spaces


def compute_gini(model):
"""Calculate gini for wealth in model.
Expand Down Expand Up @@ -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
Expand All @@ -101,7 +102,7 @@ def step(self):
self.give_money()


if __name__ == '__main__':
if __name__ == "__main__":
model = BoltzmannWealth()
for _ in range(10):
model.step()
model.step()
1 change: 1 addition & 0 deletions mesa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions mesa/experimental/components/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 = []
Expand Down
9 changes: 7 additions & 2 deletions mesa/spaces/__init__.py
Original file line number Diff line number Diff line change
@@ -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__ = [
Expand Down
2 changes: 1 addition & 1 deletion mesa/spaces/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 6e53612

Please sign in to comment.