Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document AgentType's model variable fields #492

Closed
sbenthall opened this issue Feb 7, 2020 · 5 comments
Closed

Document AgentType's model variable fields #492

sbenthall opened this issue Feb 7, 2020 · 5 comments
Assignees
Milestone

Comments

@sbenthall
Copy link
Contributor

In tracking the relationship between HARK.AgentType and the generic MDP formalism (see #491), I'm seeing some architectural choices made that, in my opinion, make it a little harder than necessary to follow the documentation.

At the class level documentation for AgentType, it says:

Critically, every subclass of AgentType should define class-specific static values of the attributes time_vary and time_inv as lists of strings. Each element of time_vary is the name of a field in AgentSubType that varies over time in the model. Each element of time_inv is the name of a field in AgentSubType that is constant over time in the model

time_vary and time_inv are not defined as variables on the AgentType class.
They easily could be (as empty lists), and then they could be documented individually as parameters.

Some other fields associated with "model variables", like poststate_vars and track_vars, are already like this (initialized to empty lists), but for some reason are not documented in the docstring.

Another variable shock_vars, is used but not documented at all.

I'd like to make these variables more explicit in the code and document them.

@sbenthall
Copy link
Contributor Author

StackOverflow, referring to PEP257, on how to document class attributes, which while show up in Sphinx autodocs:
https://stackoverflow.com/questions/3051241/how-to-document-class-attributes-in-python

@sbenthall
Copy link
Contributor Author

@mnwhite I'm noticing that when these time_vary attributes are filled in on subclasses of AgentType, you sometimes start with a variable with a trailing underscore after the variable name, e.g.:

https://github.com/econ-ark/HARK/blob/master/HARK/ConsumptionSaving/ConsIndShockModel.py#L1595-L1598

And then later in the initializer assign it to the class:
https://github.com/econ-ark/HARK/blob/master/HARK/ConsumptionSaving/ConsIndShockModel.py#L1632-L1635

I was wondering if there's any particular reason why you implemented it this way. This use of an underscore is as far as I can tell not of any relevant standard meaning in Python:
https://hackernoon.com/understanding-the-underscore-of-python-309d1a029edc

@mnwhite
Copy link
Contributor

mnwhite commented Feb 7, 2020 via email

@sbenthall
Copy link
Contributor Author

sbenthall commented Feb 8, 2020

I see.

I see that update() is not defined on AgentType, but it is in the subclasses.

I would like to:

  • make these model variable fields into parameters passed to the AgentType initializer
  • document them
  • have the AgentType initializer call a (dummy, but documented) update()
  • have downstream classes pass their default model variable values into their superclass constructor,
  • remove the calls to update() from the subclass constructors.

The principle here is just:

  • have the critical code documented
  • push the functionality to the level of abstraction in the class hierarchy where it generalizes best.

What do you think about this plan?

@mnwhite
Copy link
Contributor

mnwhite commented Feb 8, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants