Skip to content

Raise a more informative error message. #352

@mo2561057

Description

@mo2561057

respy/respy/solve.py

Lines 74 to 88 in fd580c3

for i, choice in enumerate(optim_paras["choices"]):
if f"wage_{choice}" in optim_paras:
wage_columns = optim_paras[f"wage_{choice}"].index
log_wage = np.dot(
states[wage_columns].to_numpy(dtype=COVARIATES_DOT_PRODUCT_DTYPE),
optim_paras[f"wage_{choice}"].to_numpy(),
)
wages[:, i] = np.exp(log_wage)
if f"nonpec_{choice}" in optim_paras:
nonpec_columns = optim_paras[f"nonpec_{choice}"].index
nonpecs[:, i] = np.dot(
states[nonpec_columns].to_numpy(dtype=COVARIATES_DOT_PRODUCT_DTYPE),
optim_paras[f"nonpec_{choice}"].to_numpy(),
)

This is a part of the code that will frequently throw errors due when dealing with large models.
If there is a small spelling mistake or a corrupted row in the params file there will be a key error here.
I think we could provide the user with a more informative message indicating that this is probably due to a variable that is misspelled or not in the covariates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions