Uh oh!
There was an error while loading. Please reload this page.
(I002) setInputsCSV() - #447
Conversation
syntron
commented
Mar 18, 2026
from PR #404:
I would not do it via a pandas dataframe as this would add the dependency to OMPython; but using the dictionary would work - at the end, the current code just converts the CSV file to a dictionary to apply it to the existing data. @joewa would this work for you? |
joewa
commented
Mar 20, 2026
Yes, that would work for me @syntron . When using tables / DataFrames this helper function proved to be useful too: deftoInputs(data: dict[str, list[float]]) ->dict[str, list[tuple[float, float]]]:
""" Converts a dictionary of lists (from pandas DataFrame.to_dict(orient='list')) into the OMPython setInputs input format. Example: mod.setInputs(**toInputs(pdf.to_dict(orient='list'))) Assumes the dictionary contains a key named 'time'. """if"time"notindata:
raiseValueError("The provided data must contain a 'time' key.")
time_series=data["time"]
inputs= {
var_name: list(zip(time_series, values))
forvar_name, valuesindata.items()
ifvar_name!="time"
}
returninputsShall we add it as well? |
syntron
commented
Apr 1, 2026
Looks good to me! This can be added as a |
…ut to OMPython input based on code written by joewa (see OpenModelica#447 (comment))
joewa
commented
Apr 6, 2026
Perfect! |
a3f61ed to
f7d2e68Compare[README.md] small updates [__init__] small updates
* ModelExecutionData => ModelExecutionRun * ModelExecutionCmd => ModelExecutionConfig
[pylint] fix 'R1729: Use a generator instead 'all(isinstance(item, tuple) for item in val_evaluated)' (use-a-generator)' [pylint] fix 'W0237: Parameter 'expr' has been renamed to 'command' in overriding 'OMCSessionZMQ.sendExpression' method (arguments-renamed)' [pylint] [OM*Path*] fix pylint messags about incompatible definitions
[ModelExecutionException] catch exception if ModelExecutionCmd.run() is used [bugfix] [ModelicaSystem] fix exception; use ModelicaSystemError (instead of wrong ModelExecutionException) [bugfix] [ModelicaSystemABC] fix _prepare_input_data() - ensure returned data is dict[str, str]
[compatibility] add class wrapper to provide the depreciation message [ModelicaSystem] fix / improve wrapper functions for v4.0.0 compatibility [ModelicaSystemABC] additional checks for setInputs() [test_ModelicaSystemOMC] add tests for setInputs() [__init__] define ModelicaSystemDoE at the right point (=> compatibility layer) [__init__] remove duplicate 'OMCSessionABC' in __all__
[ModelicaSystemABC] remove code for (depreciated) arguments in set*() methods * define code in the compatibility layer in class ModelicaSystem [test_ModelicaSystem(OMC)] update tests * for new version: remove usage of old definition * for compatibility version: test old definition
[OMCSessionABC] remove execute(); still available in compatibility v4.0.0 [ModelicaSystem] define _set_compatibility_helper() as static [ModelExecutionCmd] remove depreciated simflags [test_ModelSystemCmd/ModelExecutionCmd] fix test due to changes [ModelicaSystemCmd] cleanup - do not define (unused / not useable) class
…ased on the content of a CSV file
…ut to OMPython input based on code written by joewa (see OpenModelica#447 (comment))
Read content from a CSV file and use it to define the time based input data.
See issue #353 - currently completly untested from my side!
@FaBiasch could you please tests?