State Update Function PSUB key not checked
BenSchZA opened this issue · 2 comments
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,
}
}
]
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?
@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