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

Add constructor architecture #1410

Merged
merged 45 commits into from
May 21, 2024
Merged

Add constructor architecture #1410

merged 45 commits into from
May 21, 2024

Commits on Apr 15, 2024

  1. First draft of construct() method

    Completely untested, will adapt construct_income_process on next commit as test example.
    mnwhite committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    a036f24 View commit details
    Browse the repository at this point in the history
  2. IncShkDstn is constructed using construct

    Holy crap, construct() worked on the first try! Only IncShkDstn has been tested, and none of the "error catching" features have been looked at. But hey, it works!
    mnwhite committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    4d3e407 View commit details
    Browse the repository at this point in the history
  3. Add missing constructor lines to ConsAggShock

    Should pass these tests now, but formatting is probably still wrong.
    mnwhite committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    0b96804 View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2024

  1. Add make_univariate, simplify formatting

    Can now collapse a DiscreteDistribution to a single dimension; PermShkDstn and TranShkDstn are made this way now. Moved bespoke constructor dictionary lines out of init. Future plan: each AgentType subclass should have default constructors dictionary in its parameter dictionary.
    mnwhite committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    1d56aa8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f440295 View commit details
    Browse the repository at this point in the history
  3. Turn lists into TimeVaryingDiscreteDistributions

    One test was failing due to lack of seed.
    mnwhite committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    613fa5c View commit details
    Browse the repository at this point in the history
  4. Run black on changed files

    mnwhite committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    35cf624 View commit details
    Browse the repository at this point in the history
  5. Properly run pre-commit

    mnwhite committed Apr 24, 2024
    Configuration menu
    Copy the full SHA
    51ed70e View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2024

  1. Add aXtraGrid and solution_terminal to constructors

    All tests pass except for calc_jacobian, which needs a separate fix.
    mnwhite committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    ad6994d View commit details
    Browse the repository at this point in the history
  2. Fix syntax in asset grid test

    Missed this one. Jacobian test will still be failing.
    mnwhite committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    3c5b2c7 View commit details
    Browse the repository at this point in the history
  3. Fix odd behavior of calc_jacobian

    All test should pass now. Added new optional input for AgentType.solve() that allows the user to decline to run the presolve routine. For most of our classes, presolve might update the terminal solution and/or run update/constructor methods, but this is fatal to what calc_jacobian wants to do.
    mnwhite committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    fd1dd45 View commit details
    Browse the repository at this point in the history
  4. Fix indexing error in distribution tests

    I think something about pytest just changed while I was working on this branch, because three tests needed to have a [0] added to them (to reference the only element in the array) in order to be correct. Nothing changed, but the result of these tests did. I'm confused.
    mnwhite committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    ff134b6 View commit details
    Browse the repository at this point in the history
  5. Missed one index spot

    mnwhite committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    bdc2b0f View commit details
    Browse the repository at this point in the history
  6. Change two tests to AlmostEqual

    One assertEqual test was off by 1e-16 on Python 3.9, but not 3.10. No idea why.
    mnwhite committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    154512d View commit details
    Browse the repository at this point in the history
  7. Adjust notation in examples

    Also added retro support for using [None] rather than None for aXtraExtra.
    mnwhite committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    38c376b View commit details
    Browse the repository at this point in the history

Commits on Apr 27, 2024

  1. Two more tiny fixes

    mnwhite committed Apr 27, 2024
    Configuration menu
    Copy the full SHA
    f1f963e View commit details
    Browse the repository at this point in the history

Commits on May 7, 2024

  1. Move general income process objects to constructors

    pLvlGrid and pLvlNextFunc are now built with the constructors framework. This means that the *only* difference between the AgentType subclasses in ConsGenIncProcessModel is their default dictionary. GenInc tests pass locally, committing to see what else I broke.
    mnwhite committed May 7, 2024
    Configuration menu
    Copy the full SHA
    6c6fc97 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    246874f View commit details
    Browse the repository at this point in the history
  3. Fix example notebook

    Because dictionaries now include constructor methods, two extra lines were needed. Also made the example problems consistently infinite horizon so that the comparison is relevant.
    mnwhite committed May 7, 2024
    Configuration menu
    Copy the full SHA
    0134f23 View commit details
    Browse the repository at this point in the history
  4. Remove pLvlGrid dependence on AgentCount

    This makes object used for the solution not depend on simulation parameter. Test results were slightly adjusted to account for grid change. Tests passed on the commit immediately prior to this one, hence the *very* specific commit.
    mnwhite committed May 7, 2024
    Configuration menu
    Copy the full SHA
    2a23106 View commit details
    Browse the repository at this point in the history
  5. Missed two test values

    mnwhite committed May 7, 2024
    Configuration menu
    Copy the full SHA
    35fadae View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    070cd83 View commit details
    Browse the repository at this point in the history

Commits on May 8, 2024

  1. Move RiskyDstn, ShkDstn, ShareLimit to constructors

    The portfolio / risky-asset model constructed inputs have been ported into the constructors framework. I didn't put the simulation-only object AdjustDstn into this form, nor did I put the one-liner ShareGrid constructor. The latter should probably be moved later-- it's not hard, I just got lazy when it's a one line method to make a uniform grid on [0,1].
    mnwhite committed May 8, 2024
    Configuration menu
    Copy the full SHA
    e5a85b4 View commit details
    Browse the repository at this point in the history
  2. Fix spelling

    Fixed a spelling error in one place, so had to fix it where it was imported.
    mnwhite committed May 8, 2024
    Configuration menu
    Copy the full SHA
    9638460 View commit details
    Browse the repository at this point in the history
  3. Fix dictionary imports in examples

    Due to presence of constructors, two examples needed a different dictionary as their base.
    mnwhite committed May 8, 2024
    Configuration menu
    Copy the full SHA
    1b03e14 View commit details
    Browse the repository at this point in the history
  4. Move PrefShkDstn to constructor format

    Tests pass, committing to see which examples break.
    mnwhite committed May 8, 2024
    Configuration menu
    Copy the full SHA
    1265977 View commit details
    Browse the repository at this point in the history
  5. Move MedShkDstn to constructor format

    Tests pass, hopefully examples will too.
    mnwhite committed May 8, 2024
    Configuration menu
    Copy the full SHA
    4ffee80 View commit details
    Browse the repository at this point in the history

Commits on May 9, 2024

  1. Add describe_constructors method

    AgentType now has a helper method called describe_constructors that prints to screen the status of constructed objects, including their names, the required primitive inputs, and whether each value exists.
    mnwhite committed May 9, 2024
    Configuration menu
    Copy the full SHA
    f905c8f View commit details
    Browse the repository at this point in the history

Commits on May 10, 2024

  1. Move AggShock terminal solution to constructor

    Also deleted long-unused commented out code.
    mnwhite committed May 10, 2024
    Configuration menu
    Copy the full SHA
    0c2e5ed View commit details
    Browse the repository at this point in the history
  2. Forgot to actually delete old method

    Prior commit was actually trivial, as it didn't delete the prior update_solution_terminal!
    mnwhite committed May 10, 2024
    Configuration menu
    Copy the full SHA
    e74a269 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    019e39b View commit details
    Browse the repository at this point in the history
  4. Typo in dictionary key

    Very silly
    mnwhite committed May 10, 2024
    Configuration menu
    Copy the full SHA
    6fdacdc View commit details
    Browse the repository at this point in the history
  5. And typo in dictionary value

    Never make last second changes before committing, kids. You will never get it right and only embarrass yourself through the commit history.
    mnwhite committed May 10, 2024
    Configuration menu
    Copy the full SHA
    e79d786 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a9a9df6 View commit details
    Browse the repository at this point in the history
  7. Fix portfolio and bequest examples

    Minor errors in code and dictionaries due to changes in prior commit.
    mnwhite committed May 10, 2024
    Configuration menu
    Copy the full SHA
    f92b29f View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    22efb70 View commit details
    Browse the repository at this point in the history

Commits on May 13, 2024

  1. Move Markov terminal solution to constructor

    Also had to change dictionary import in tests. Notebooks might break.
    mnwhite committed May 13, 2024
    Configuration menu
    Copy the full SHA
    243bdd7 View commit details
    Browse the repository at this point in the history
  2. Fix MPC in terminal solution

    Too much copy-pasta, something ended up zero that should have been one.
    mnwhite committed May 13, 2024
    Configuration menu
    Copy the full SHA
    a8eadab View commit details
    Browse the repository at this point in the history
  3. Add two example constructors for MrkvArray

    One is an extremely basic binary state specification, the other is a "ratchet" specification in which transitions only go one direction, and only one step at a time.
    mnwhite committed May 13, 2024
    Configuration menu
    Copy the full SHA
    32f3f51 View commit details
    Browse the repository at this point in the history
  4. Fix dictionary import in one example notebook

    Same issue as in earlier commit, but in an example notebook. Just imported and used correct dictionary.
    mnwhite committed May 13, 2024
    Configuration menu
    Copy the full SHA
    6df9acb View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    fa6030a View commit details
    Browse the repository at this point in the history

Commits on May 14, 2024

  1. Added error logging functionality to construct

    Construct method is now more robust, with an option to force through errors and record them in a separate dictionary. Also made other small changes/fixes.
    mnwhite committed May 14, 2024
    Configuration menu
    Copy the full SHA
    b282159 View commit details
    Browse the repository at this point in the history
  2. Add a few alternate constructors

    This commit adds one missing (trivial) constructor and adds a few "counterexample" constructors that *could* be used for other parameter specifications. There are many, many more that could be written.
    mnwhite committed May 14, 2024
    Configuration menu
    Copy the full SHA
    357e412 View commit details
    Browse the repository at this point in the history
  3. Add CHANGELOG entry

    Also added one missing line of documentation.
    mnwhite committed May 14, 2024
    Configuration menu
    Copy the full SHA
    5b9d91d View commit details
    Browse the repository at this point in the history

Commits on May 21, 2024

  1. Configuration menu
    Copy the full SHA
    d82714c View commit details
    Browse the repository at this point in the history