-
Notifications
You must be signed in to change notification settings - Fork 1
Description
File paths point to a specific location on Yannick's laptop. E.g os.chdir("C:/Users/earyo/Dropbox/Arbeit/postdoc_leeds/ABM_python_first_steps/implement_own_covid_policy_model"). This means that other people wont be able to run the code. You should use relative paths.
In a notebook this is quite straightforward as I think the notebook directory is always set to be the place where the notebook is stored. E.g. if I open run_base_model_and_filter_with_plotting_jupyter.ipynb and do %pwd (it's a notebook command that says show me the _p_resent _w_orking _d_irectory) then I get /Users/nick/gp/Covid_policy_response_abm, which is the directory on my machine where the notebook is stored. So any other files can be referenced from that directory.
This means that lines like this:
with open('C:/Users/earyo/Dropbox/Arbeit/postdoc_leeds/ABM_python_first_steps/implement_own_covid_policy_model/data/correlation_between_policies_and_metrics.csv') as f:can be replaced with simply:
with open('./data/correlation_between_policies_and_metrics.csv') as f:(the . is unnecessary but I like it because it says explicitly that the directory to start from is the current directory)
Sometimes it is slightly trickier with code and packages, but we can come on to that if it's a problem...