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

State Update Function PSUB key not checked #259

Open
BenSchZA opened this issue Mar 26, 2021 · 2 comments
Open

State Update Function PSUB key not checked #259

BenSchZA opened this issue Mar 26, 2021 · 2 comments

Comments

@BenSchZA
Copy link
Member

In the following notebook, the variables dictionary keys are not checked to match against the state update function keys: https://github.com/cadCAD-org/snippets/blob/main/snippets/execution_time_decorator.ipynb

We'd expect the following code, where the key 'a' has a state update function for key 'b', to throw an error when executed by cadCAD, but no error is thrown.

psubs = [
  {
    'policies': {},
    'variables': {
      'a': update_b,
      'b': update_a,
    }
  }
]
@danlessa
Copy link
Member

From a design standpoint, the most elegant solution would be to drop referencing the state variable on the SUF itself, and only mention the state variable being updated on the psubs

Checking the function output is also likely to be infeasible for a variety of use cases. The only way for not breaking the API is if we adopt an explicit convention of what's the expected behavior. Should it be updated based on the SUF return or should it be updated based on the PSUBs key?

@BenSchZA
Copy link
Member Author

@danlessa could you expand on Checking the function output is also likely to be infeasible for a variety of use cases.? In radCAD, I check that the PSUB and function return keys match, and otherwise throw an error f"PSU state key {state} doesn't match function state key {state_key}", but maybe cadCAD has some other constraints that make this check infeasible.

See https://github.com/CADLabs/radCAD/blob/fcfd62c6dafa6d4b416c838767107df9d9944ce1/radcad/core.py#L202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants