-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Model parameter getters and setters modeled on NetworkX methods #679
Comments
This requirement is, on its surface, at odds with the idea of namespacing parameters #660 At this time when this issue was written, this user interface was considered important. What is troublesome from a software design perspective about this is that there are currently multiple ways to reset a parameter. There is this way: setting it via an attribute setter. There is also the way the https://github.com/econ-ark/HARK/blob/master/HARK/core.py#L172-L177 This violates the Zen of Python: o"There should be one-- and preferably only one --obvious way to do it." (see Zen of Python) We need to give up one of these ways of doing things. Which will it be? We can either:
Because |
This is related to #640 . The use case is when the user wants to change the standard deviation of the income distribution and rerun the model. Currently, changing this parameter will not reconstruct the internally used discretized distribution object. |
The question underlying this issue is whether and how to commit HARK models to an underlying data structure. This documentation about the data structure of Graphs in NetworkX is informative and a nice example of a clearlyly defined data structure for a scientific library. https://networkx.org/documentation/stable/reference/introduction.html#data-structure As we move towards more configurable model definition and flexible modeling architecture, our models cease being code and become a kind of data. That implies the need to define our data structure. That suggests that we should not be supporting the setting of model properties through attribute getters and setters. If we follow the pattern of NetworkX (a library I like very much, personally), we would have methods like I'm feeling confident about this and so will change the name and purpose of this ticket to making a model parameter setting method. If there's pushback on this, I'll keep trying to argue the point. |
Ah. This is close to what |
maybe it doesn't need to be |
Currently, HARK users are encouraged to dynamically reset model parameters on the model class like so:
Here
DiscFac
is being reset by the user after initialization.This use of a public attribute is in fact Pythonic. (I was incorrect earlier about using getters and setters in Python). But there are ways to set up hooks when the value is set using the
@property
decorator:https://www.python-course.eu/python3_properties.php
This might be useful for testing conditions (for example, that
Rboro > Rsave
) when the model is being modified.It may also be useful for storing the values in a way that is easier to programmatically access later. Ideally, there would be a way to export or display all the currently set model parameters as a dictionary (or some other format) and this is currently impossible. See #446
The text was updated successfully, but these errors were encountered: