Skip to content

Commit

Permalink
Update __repr__ with hoodnum
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoutH authored and tpike3 committed Sep 26, 2024
1 parent b316a41 commit 4e22c5c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/tutorials/intro_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
" )\n",
"\n",
" def __repr__(self):\n",
" return f\"Neighbourhood {self.unique_id}\"\n",
" return f\"Neighbourhood {self.HOODNUM}\"\n",
" \n",
" def step(self):\n",
" \"\"\"Advance agent one step.\"\"\"\n",
Expand Down Expand Up @@ -278,7 +278,7 @@
},
"source": [
"\n",
"First, we name our class in this case GeoSIR and we inherit the model class from Mesa. We store the path to our GeoJSON file in the object geojson regions. As JSONs mirror Pythons dictionary structure, we store the key for the neighbourhood id (\"HOODNUM\") in the variable unique_id (TODO: Update).\n",
"First, we name our class in this case GeoSIR and we inherit the model class from Mesa. We store the path to our GeoJSON file in the object geojson regions. As JSONs mirror Pythons dictionary structure, we store the key for the neighbourhood id (\"HOODNUM\") as attribute, and update the __repr__ function to print out the neighbourhood id.\n",
"\n",
"Second, we set up the python initializer to initiate our model class. To do this we will, set up key word arguments or kwargs of the parameters we want for our model. In this case we will use: \n",
"- population size (pop_size): An integer that determines the number of person agents\n",
Expand Down Expand Up @@ -352,7 +352,6 @@
" # Set up the Neighbourhood patches for every region in file\n",
" ac = mg.AgentCreator(NeighbourhoodAgent, model=self)\n",
" neighbourhood_agents = ac.from_file(self.geojson_regions)\n",
" # TODO: Check if the HOODNUM still needed, and if so, is read correctly\n",
" \n",
" #Add neighbourhood agents to space\n",
" self.space.add_agents(neighbourhood_agents)\n",
Expand Down Expand Up @@ -450,7 +449,7 @@
"\n",
"You can also see all the person agents are called and then the neighbourhood agents. This will become important later as we want to update the neighbourhood status later based on its PersonAgent status. \n",
"\n",
"If you are curious about the numbers for the neighbourhood agents, you can open up the GeoJSON in the data folder and see that each neighborhood gets a unique id identified by `HOODNUM` to ensure this number does not cause a conflict with our agent numbers, we add a \"P\" to their ID. \n",
"If you are curious about the numbers for the neighbourhood agents, you can open up the GeoJSON in the data folder and see that each neighborhood gets a `HOODNUM` attribute assigned.\n",
"\n"
]
},
Expand Down Expand Up @@ -758,7 +757,6 @@
"\n",
" # Geographical parameters for desired map\n",
" geojson_regions = \"data/TorontoNeighbourhoods.geojson\"\n",
" unique_id = \"HOODNUM\" # TODO: Either use or remove\n",
"\n",
" def __init__(\n",
" self, pop_size=30, mobility_range=500, init_infection=0.2, exposure_dist=500, max_infection_risk=0.2,\n",
Expand Down

0 comments on commit 4e22c5c

Please sign in to comment.