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

Implement test for options #146

Open
wants to merge 3 commits into
base: new_spars_rebranch
Choose a base branch
from
Open

Conversation

MaxBlesch
Copy link
Member

@MaxBlesch MaxBlesch commented Jan 10, 2025

Suggested Additional Checks for check_options_and_set_defaults

  • Check for continuous_states dict in options dict
  • Check for missing continuous_states keys always present like wealth:
  • Ensure wealth exists in continuous_states.
  • Check its type (e.g., list, np.ndarray) and convert

  • Ensure all continuous_states values are convertible to np.ndarray and then convert them to np.ndarrays

  • Validate n_choices matches choices length
    - If n_choices exists in model_params, ensure it equals the length of choices

  • Enforce positive extra_wealth_grid_factor ?

  • Add a check for tuning_params keys: If provided, validate their types

Implemented Checks for check_options_and_set_defaults (that are also tested)

Validation Checks

  • Ensure options is a dictionary.
  • Ensure options contains a state_space dictionary.
  • Ensure state_space is a dictionary.
  • Ensure state_space contains n_periods.
  • Ensure n_periods is an integer.
  • Ensure n_periods is greater than 1.
  • Ensure choices in state_space is either a list, integer, or numpy array (if provided).
  • Convert choices to a numpy array of type uint8 if present.

Default Setting

  • Set default choices to a numpy array [0] of type uint8 if not provided.
  • Set default tuning_params to an empty dictionary if not provided.
  • Set default tuning_params["extra_wealth_grid_factor"] to 0.2 if not provided.
  • Set default tuning_params["n_constrained_points_to_add"] based on the length of the wealth grid if not provided.
  • Set model_params["n_choices"] based on the length of state_space["choices"] if not explicitly provided.

Logical Consistency

  • Ensure model_params is a dictionary.
  • Ensure options contains model_params.
  • Validate tuning_params to ensure the extra wealth grid factor is large enough to cover the constrained wealth grid points

Grid Preparation

  • Compute the number of wealth grid points (n_wealth_grid) from the continuous_states["wealth"] grid.
  • Compute the total wealth grid size (n_total_wealth_grid) based on extra_wealth_grid_factor and n_constrained_points_to_add.
  • Extract exogenous grids from continuous_states.

Secondary Continuous State

  • Identify and handle the second continuous state (if continuous_states has more than one key).
  • Compute the number of grid points for the second continuous state (n_second_continuous_grid).

mod Gregors Fehler

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.49%. Comparing base (4243ddf) to head (46717ff).

Additional details and impacted files
@@                  Coverage Diff                   @@
##           new_spars_rebranch     #146      +/-   ##
======================================================
+ Coverage               92.71%   93.49%   +0.77%     
======================================================
  Files                      39       39              
  Lines                    1291     1291              
======================================================
+ Hits                     1197     1207      +10     
+ Misses                     94       84      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

2 participants