Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/hotelling_law/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def test_decreasing_price_variance():

df_model = model.datacollector.get_model_vars_dataframe()

assert check_slope(
df_model["Price Variance"], increasing=False
), "The price variance should decrease over time."
assert check_slope(df_model["Price Variance"], increasing=False), (
"The price variance should decrease over time."
)


def test_constant_price_variance():
Expand All @@ -53,6 +53,6 @@ def test_constant_price_variance():

df_model = model.datacollector.get_model_vars_dataframe()

assert (
get_slope(df_model["Price Variance"]) == 0
), "The price variance constant over time."
assert get_slope(df_model["Price Variance"]) == 0, (
"The price variance constant over time."
)
5 changes: 3 additions & 2 deletions examples/warehouse/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import matplotlib.pyplot as plt
import pandas as pd
import solara
from agents import InventoryAgent
from mesa.visualization import SolaraViz
from mesa.visualization.utils import update_counter
from model import WarehouseModel

from .agents import InventoryAgent
from .model import WarehouseModel

# Constants
LOADING_DOCKS = [(0, 0, 0), (0, 2, 0), (0, 4, 0), (0, 6, 0), (0, 8, 0)]
Expand Down
2 changes: 1 addition & 1 deletion examples/warehouse/model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import mesa
from make_warehouse import make_warehouse
from mesa.discrete_space import OrthogonalMooreGrid
from mesa.discrete_space.cell_agent import CellAgent
from mesa.experimental.meta_agents.meta_agent import create_meta_agent
Expand All @@ -10,6 +9,7 @@
SensorAgent,
WorkerAgent,
)
from .make_warehouse import make_warehouse

# Constants for configuration
LOADING_DOCKS = [(0, 0, 0), (0, 2, 0), (0, 4, 0), (0, 6, 0), (0, 8, 0)]
Expand Down
18 changes: 9 additions & 9 deletions gis/agents_and_networks/src/space/campus.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import random
from collections import defaultdict
from typing import DefaultDict, Dict, Optional, Set, Tuple
from typing import DefaultDict

import mesa
import mesa_geo as mg
Expand All @@ -11,13 +11,13 @@


class Campus(mg.GeoSpace):
homes: Tuple[Building]
works: Tuple[Building]
other_buildings: Tuple[Building]
homes: tuple[Building]
works: tuple[Building]
other_buildings: tuple[Building]
home_counter: DefaultDict[mesa.space.FloatCoordinate, int]
_buildings: Dict[int, Building]
_commuters_pos_map: DefaultDict[mesa.space.FloatCoordinate, Set[Commuter]]
_commuter_id_map: Dict[int, Commuter]
_buildings: dict[int, Building]
_commuters_pos_map: DefaultDict[mesa.space.FloatCoordinate, set[Commuter]]
_commuter_id_map: dict[int, Commuter]

def __init__(self, crs: str) -> None:
super().__init__(crs=crs)
Expand Down Expand Up @@ -56,7 +56,7 @@ def add_buildings(self, agents) -> None:

def get_commuters_by_pos(
self, float_pos: mesa.space.FloatCoordinate
) -> Set[Commuter]:
) -> set[Commuter]:
return self._commuters_pos_map[float_pos]

def get_commuter_by_id(self, commuter_id: int) -> Commuter:
Expand All @@ -69,7 +69,7 @@ def add_commuter(self, agent: Commuter) -> None:

def update_home_counter(
self,
old_home_pos: Optional[mesa.space.FloatCoordinate],
old_home_pos: mesa.space.FloatCoordinate | None,
new_home_pos: mesa.space.FloatCoordinate,
) -> None:
if old_home_pos is not None:
Expand Down
6 changes: 2 additions & 4 deletions gis/agents_and_networks/src/space/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List, Tuple

import geopandas as gpd
import mesa
import numpy as np
Expand All @@ -23,7 +21,7 @@ def get_coord_matrix(

def get_affine_transform(
from_coord: np.ndarray, to_coord: np.ndarray
) -> Tuple[float, float, float, float, float, float]:
) -> tuple[float, float, float, float, float, float]:
A, res, rank, s = np.linalg.lstsq(from_coord, to_coord, rcond=None)

np.testing.assert_array_almost_equal(res, np.zeros_like(res), decimal=15)
Expand All @@ -44,7 +42,7 @@ def get_rounded_coordinate(


def segmented(lines: gpd.GeoSeries) -> gpd.GeoSeries:
def _segmented(linestring: LineString) -> List[LineString]:
def _segmented(linestring: LineString) -> list[LineString]:
return [
LineString((start_node, end_node))
for start_node, end_node in zip(
Expand Down
3 changes: 1 addition & 2 deletions gis/geo_schelling_points/geo_schelling_points/space.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import random
from typing import Dict

import mesa_geo as mg

from .agents import RegionAgent


class Nuts2Eu(mg.GeoSpace):
_id_region_map: Dict[str, RegionAgent]
_id_region_map: dict[str, RegionAgent]
num_people: int

def __init__(self):
Expand Down
4 changes: 1 addition & 3 deletions gis/rainfall/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Tuple

from mesa.visualization import Slider, SolaraViz, make_plot_component
from mesa_geo.visualization import make_geospace_component
from rainfall.model import Rainfall
Expand All @@ -13,7 +11,7 @@
}


def cell_portrayal(cell: LakeCell) -> Tuple[float, float, float, float]:
def cell_portrayal(cell: LakeCell) -> tuple[float, float, float, float]:
if cell.water_level == 0:
return cell.elevation, cell.elevation, cell.elevation, 1
else:
Expand Down
4 changes: 1 addition & 3 deletions gis/urban_growth/app.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import Tuple

import solara
from mesa.visualization import Slider, SolaraViz, make_plot_component
from mesa_geo.visualization import make_geospace_component
from urban_growth.model import UrbanGrowth
from urban_growth.space import UrbanCell


def cell_portrayal(cell: UrbanCell) -> Tuple[float, float, float, float]:
def cell_portrayal(cell: UrbanCell) -> tuple[float, float, float, float]:
if cell.urban:
if cell.old_urbanized:
return 0, 0, 255, 1
Expand Down
Loading