Skip to content

Commit 6732bd7

Browse files
authored
ModelicaSystem - rewrite set*() functions (#314)
* [ModelicaSystem] add type hints for set*() functions and rename arguments * fix some type hint issues in setInput() * prepare for definition via dictionary replacing 'a=b' and '[a=b, c=d]' style * [ModelicaSystem] add _prepare_inputdata() * [ModelicaSystem] update _set_method_helper() * rename from setMethodHelper() * use _prepare_inputdata() * cleanup code to align with new input as dict[str, str] * setInput() is a special case * [ModelicaSystem] improve definition of _prepare_inputdata() * [ModelicaSystem] rename _prepare_inputdata() => _prepare_input_data() * [ModelicaSystem] update setInput() * replace eval() with ast.literal_eval() as a saver version * use _prepare_input_data() * simplify code * update tests - use new dict based input for set*() methods * [ModelicaSystem] add type hint for return value of isParameterChangeable() * [ModelicaSystem] fix type hint for _prepare_input_data() - use dict[str, Any] * [ModelicaSystem] setInput() - handly input data as list of tuples This method is used to set input values. It can be called with a sequence of input name and assigning corresponding values as arguments as show in the example below. Compared to other set*() methods this is a special case as value could be a list of tuples - these are converted to a string in _prepare_input_data() and restored here via ast.literal_eval(). * update tests - use new dict based input for setInput() method * [test_linearization] fix setInput() call * [ModelicaSystem] simplify _set_method_helper() * [ModelicaSystem] improve setInputs() - reduce spaces / cleanup * [ModelicaSystem] fix rebase fallout * [ModelicaSystem] fix rebase fallout 2 * [ModelicaSystem] remove _has_inputs - is defined by _inputs empty or not * [test_ModelicaSystem] cleanup * [ModelicaSystem] simplify handling of inputs * [ModelicaSystem._set_method_helper] fail if parameter is *NOT* changeable * if this happens, the result would be unexpected * fail early, fail hard to indicate this to the user * simplify code * [ModelicaSystem] rename overwritedata => overridedata
1 parent 3e9c55b commit 6732bd7

4 files changed

Lines changed: 258 additions & 157 deletions

File tree

0 commit comments

Comments
 (0)