yannickoswald / covpol

COVPOL: An agent-based model of the international COVID-19 policy response
3 stars 1 forks source link

`ClassMethod` #13

Closed nickmalleson closed 1 year ago

nickmalleson commented 1 year ago

In the agent_class.reset() function:

https://github.com/eeyouol/Covid_policy_response_abm/blob/da92205d3542eac18b6a499d9cc7bfb1aadcf04f/code/agent_class.py#L269

you should explicitly tell python that it is a class method, not an object method.

Currently it is:

    def reset(cls):
        CountryAgent.instances = []

But I think it should be:

    @clasmethod
    def reset(cls):
        cls.instances = []

The beaviour is the same for both functions, but for the first one you need an agent object to access it (e.g. agent.reset()) whereas with the other you can call it without access to a particular agent object (e.g. CountryAgent.reset()).

yannickoswald commented 1 year ago

done.