cadCAD-org / cadCAD

Design, simulate, validate, and operate within complex systems
https://cadcad.org
MIT License
555 stars 271 forks source link

Unhelpful error message when mechanism does not have return signature #288

Closed jds3d closed 11 months ago

jds3d commented 3 years ago

In the case where a mechanism like:

def account_for_tax(params, step, sL, s, inputs): key = 'GRT' delegation_tokens_quantity = inputs['delegation_tokens_quantity'] delegation_tax_rate = params['delegation_tax_rate']

tax = delegation_tax_rate * delegation_tokens_quantity
value = s['GRT'] - tax
**return key, value**

does not have the bold part (return key, value), you get the following error message:

c:\Users\Josh\anaconda3\envs\py396\lib\site-packages\cadCAD\engine\simulation.py in state_update_pipeline(self, sweep_dict, simulation_list, configs, env_processes, time_step, run, additional_objs) 172 sub_step += 1 173 for [s_conf, p_conf] in configs: --> 174 states_list: List[Dict[str, Any]] = self.partial_state_update( 175 sweep_dict, sub_step, states_list, simulation_list, s_conf, p_conf, env_processes, time_step, run, 176 additional_objs c:\Users\Josh\anaconda3\envs\py396\lib\site-packages\cadCAD\engine\simulation.py in partial_state_update(self, sweep_dict, sub_step, sL, sH, state_funcs, policy_funcs, env_processes, time_step, run, additional_objs) 138 return destination 139 --> 140 last_in_copy: Dict[str, Any] = transfer_missing_fields(last_in_obj, dict(generate_record(state_funcs))) 141 last_in_copy: Dict[str, Any] = self.apply_env_proc(sweep_dict, env_processes, last_in_copy) 142 last_in_copy['substep'], last_in_copy['timestep'], last_in_copy['run'] = sub_step, time_step, run TypeError: cannot convert dictionary update sequence element #1 to a sequence

It would be more helpful to say which mechanism had the issue and what the issue was.