diff --git a/examples/boid_flockers/Flocker Test.ipynb b/examples/boid_flockers/Flocker Test.ipynb index 664019e5..82ecc47b 100644 --- a/examples/boid_flockers/Flocker Test.ipynb +++ b/examples/boid_flockers/Flocker Test.ipynb @@ -8,9 +8,8 @@ }, "outputs": [], "source": [ - "from boid_flockers.model import BoidFlockers\n", - "import numpy as np\n", "import matplotlib.pyplot as plt\n", + "from boid_flockers.model import BoidFlockers\n", "\n", "%matplotlib inline" ] diff --git a/examples/el_farol/el_farol.ipynb b/examples/el_farol/el_farol.ipynb index 3002b261..b043c98b 100644 --- a/examples/el_farol/el_farol.ipynb +++ b/examples/el_farol/el_farol.ipynb @@ -7,9 +7,7 @@ "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", - "import numpy as np\n", "import seaborn as sns\n", - "\n", "from el_farol.model import ElFarolBar" ] }, diff --git a/examples/epstein_civil_violence/Epstein Civil Violence.ipynb b/examples/epstein_civil_violence/Epstein Civil Violence.ipynb index 2fe5ed25..e5d4d9a2 100644 --- a/examples/epstein_civil_violence/Epstein Civil Violence.ipynb +++ b/examples/epstein_civil_violence/Epstein Civil Violence.ipynb @@ -17,11 +17,8 @@ "metadata": {}, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", - "\n", "%matplotlib inline\n", "\n", - "from epstein_civil_violence.agent import Citizen, Cop\n", "from epstein_civil_violence.model import EpsteinCivilViolence" ] }, diff --git a/examples/forest_fire/Forest Fire Model.ipynb b/examples/forest_fire/Forest Fire Model.ipynb index db9be720..afe4142a 100644 --- a/examples/forest_fire/Forest Fire Model.ipynb +++ b/examples/forest_fire/Forest Fire Model.ipynb @@ -27,17 +27,16 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as np\n", - "\n", "import matplotlib.pyplot as plt\n", + "import numpy as np\n", "\n", "%matplotlib inline\n", "\n", - "from mesa import Model, Agent\n", - "from mesa.time import RandomActivation\n", - "from mesa.space import Grid\n", + "from mesa import Agent, Model\n", + "from mesa.batchrunner import BatchRunner\n", "from mesa.datacollection import DataCollector\n", - "from mesa.batchrunner import BatchRunner" + "from mesa.space import Grid\n", + "from mesa.time import RandomActivation" ] }, { @@ -327,9 +326,9 @@ "metadata": {}, "outputs": [], "source": [ - "fixed_params = dict(height=50, width=50) # Height and width are constant\n", + "fixed_params = {\"height\": 50, \"width\": 50} # Height and width are constant\n", "# Vary density from 0.01 to 1, in 0.01 increments:\n", - "variable_params = dict(density=np.linspace(0, 1, 101)[1:])" + "variable_params = {\"density\": np.linspace(0, 1, 101)[1:]}" ] }, { diff --git a/examples/pd_grid/analysis.ipynb b/examples/pd_grid/analysis.ipynb index 7f848318..1fe69759 100644 --- a/examples/pd_grid/analysis.ipynb +++ b/examples/pd_grid/analysis.ipynb @@ -34,12 +34,9 @@ "metadata": {}, "outputs": [], "source": [ - "from pd_grid.model import PdGrid\n", - "\n", - "import numpy as np\n", - "\n", "import matplotlib.pyplot as plt\n", - "import matplotlib.gridspec\n", + "import numpy as np\n", + "from pd_grid.model import PdGrid\n", "\n", "%matplotlib inline" ] @@ -75,7 +72,7 @@ " grid[y][x] = 0\n", " ax.pcolormesh(grid, cmap=bwr, vmin=0, vmax=1)\n", " ax.axis(\"off\")\n", - " ax.set_title(\"Steps: {}\".format(model.schedule.steps))" + " ax.set_title(f\"Steps: {model.schedule.steps}\")" ] }, { diff --git a/examples/wolf_sheep/wolf_sheep/agents.py b/examples/wolf_sheep/wolf_sheep/agents.py index eef30d54..460c4abb 100644 --- a/examples/wolf_sheep/wolf_sheep/agents.py +++ b/examples/wolf_sheep/wolf_sheep/agents.py @@ -29,7 +29,7 @@ def step(self): # If there is grass available, eat it this_cell = self.model.grid.get_cell_list_contents([self.pos]) - grass_patch = [obj for obj in this_cell if isinstance(obj, GrassPatch)][0] + grass_patch = next(obj for obj in this_cell if isinstance(obj, GrassPatch)) if grass_patch.fully_grown: self.energy += self.model.sheep_gain_from_food grass_patch.fully_grown = False diff --git a/gis/agents_and_networks/src/model/model.py b/gis/agents_and_networks/src/model/model.py index 954440ff..9e4ca37c 100644 --- a/gis/agents_and_networks/src/model/model.py +++ b/gis/agents_and_networks/src/model/model.py @@ -156,9 +156,9 @@ def _load_buildings_from_file( buildings_df = buildings_df.set_crs(self.data_crs, allow_override=True).to_crs( crs ) - buildings_df["centroid"] = [ - (x, y) for x, y in zip(buildings_df.centroid.x, buildings_df.centroid.y) - ] + buildings_df["centroid"] = list( + zip(buildings_df.centroid.x, buildings_df.centroid.y) + ) building_creator = mg.AgentCreator(Building, model=self) buildings = building_creator.from_GeoDataFrame(buildings_df) self.space.add_buildings(buildings) diff --git a/pyproject.toml b/pyproject.toml index d27a43bb..dee5476b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,6 +69,7 @@ extend-ignore = [ ] # Hardcode to Python 3.8. target-version = "py38" +extend-include = ["*.ipynb"] [tool.isort] profile = "black"