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

change _hist constructions to history namespace #674

Merged
merged 8 commits into from
May 28, 2020

Conversation

sbenthall
Copy link
Contributor

Towards #495 ...

In the current functionality, during a simulation the state history is stored on the model object in fields named X_hist.
These state variables are being accessed with getattr and set with setattr.

This PR replaces storage on the object with storage in a dictionary.
So, X_hist is replaced with history[X].

There are several reasons for this change:

  • Dictionaries are faster than objects. https://gist.github.com/jessicald/2861038
  • The use of objects for storage of model state is part of a design that relies on a lot of switching between representing model variables as strings and representing them as attributes. This design has encouraged a lot of hard-coding of functionality that would ideally be implemented on more general data structures. This is a small step in that direction.

Note: the PR currently passes tests, but it looks like it may break the functionality of ConsAggShockModel. New tests for ConsAggShock are introduced in #654. Please merge that PR first.

@sbenthall sbenthall requested a review from MridulS May 6, 2020 17:07
@sbenthall
Copy link
Contributor Author

I guess this doesn't break the AggShockModel

@mnwhite
Copy link
Contributor

mnwhite commented May 7, 2020 via email

@sbenthall
Copy link
Contributor Author

If this change looks good, then the next very low hanging fruit is to replace the setattr and getattrs used for the "now" values to also be replaced with a dictionary, maybe called state.

@mnwhite
Copy link
Contributor

mnwhite commented May 7, 2020 via email

@sbenthall
Copy link
Contributor Author

Hmmm. Ok, I definitely like the idea of putting them in separate namespaces.

I'll work that out in a different PR, after this one is merged.

@sbenthall
Copy link
Contributor Author

Feature passes the review, need to fix it in examples.

@mnwhite
Copy link
Contributor

mnwhite commented May 21, 2020

Try to make examples work with this. CDC also wants DEMARKS to work.

@sbenthall
Copy link
Contributor Author

I can't make DemARKs work with code that is not yet committed to HARK.
This is an order of operations issue.

@mnwhite
Copy link
Contributor

mnwhite commented May 21, 2020 via email

@sbenthall
Copy link
Contributor Author

Latest commit should fix examples

@mnwhite
Copy link
Contributor

mnwhite commented May 22, 2020 via email

@mnwhite
Copy link
Contributor

mnwhite commented May 28, 2020

...I really thought I merged this right after the examples were working.

@mnwhite mnwhite merged commit d244cfd into econ-ark:master May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants