2828 ModelicaDoEOMC ,
2929)
3030
31+ from OMPython .compatibility_v400 import (
32+ depreciated_class ,
33+ )
34+
3135# define logger using the current module name as ID
3236logger = logging .getLogger (__name__ )
3337
3438
39+ @depreciated_class (msg = "Please use class ModelicaSystemOMC instead!" )
3540class ModelicaSystem (ModelicaSystemOMC ):
3641 """
3742 Compatibility class.
@@ -67,58 +72,167 @@ def __init__(
6772 def setCommandLineOptions (self , commandLineOptions : str ):
6873 super ().set_command_line_options (command_line_option = commandLineOptions )
6974
70- def setContinuous ( # type: ignore[override]
75+ def _set_compatibility_helper (
76+ self ,
77+ pkey : str ,
78+ args : Any ,
79+ kwargs : dict [str , Any ],
80+ ) -> Any :
81+ param = None
82+ if len (args ) == 1 :
83+ param = args [0 ]
84+ if param is None and pkey in kwargs :
85+ param = kwargs [pkey ]
86+
87+ return param
88+
89+ def setContinuous (
7190 self ,
72- cvals : str | list [str ] | dict [str , Any ],
91+ * args : Any ,
92+ ** kwargs : dict [str , Any ],
7393 ) -> bool :
74- if isinstance (cvals , dict ):
75- return super ().setContinuous (** cvals )
76- raise ModelicaSystemError ("Only dict input supported for setContinuous()" )
94+ """
95+ Compatibility wrapper for setContinuous() from OMPython v4.0.0
96+
97+ Original definition:
7798
78- def setParameters ( # type: ignore[override]
99+ ```
100+ def setContinuous(
101+ self,
102+ cvals: str | list[str] | dict[str, Any],
103+ ) -> bool:
104+ ```
105+ """
106+ param = self ._set_compatibility_helper (pkey = 'cvals' , args = args , kwargs = kwargs )
107+ if param is None :
108+ raise ModelicaSystemError ("Invalid input for setContinuous() (v4.0.0 compatibility mode)." )
109+
110+ return super ().setContinuous (param )
111+
112+ def setParameters (
79113 self ,
80- pvals : str | list [str ] | dict [str , Any ],
114+ * args : Any ,
115+ ** kwargs : dict [str , Any ],
81116 ) -> bool :
82- if isinstance (pvals , dict ):
83- return super ().setParameters (** pvals )
84- raise ModelicaSystemError ("Only dict input supported for setParameters()" )
117+ """
118+ Compatibility wrapper for setParameters() from OMPython v4.0.0
119+
120+ Original definition:
85121
86- def setOptimizationOptions ( # type: ignore[override]
122+ ```
123+ def setParameters(
124+ self,
125+ pvals: str | list[str] | dict[str, Any],
126+ ) -> bool:
127+ ```
128+ """
129+ param = self ._set_compatibility_helper (pkey = 'pvals' , args = args , kwargs = kwargs )
130+ if param is None :
131+ raise ModelicaSystemError ("Invalid input for setParameters() (v4.0.0 compatibility mode)." )
132+
133+ return super ().setParameters (param )
134+
135+ def setOptimizationOptions (
87136 self ,
88- optimizationOptions : str | list [str ] | dict [str , Any ],
137+ * args : Any ,
138+ ** kwargs : dict [str , Any ],
89139 ) -> bool :
90- if isinstance (optimizationOptions , dict ):
91- return super ().setOptimizationOptions (** optimizationOptions )
92- raise ModelicaSystemError ("Only dict input supported for setOptimizationOptions()" )
140+ """
141+ Compatibility wrapper for setOptimizationOptions() from OMPython v4.0.0
142+
143+ Original definition:
93144
94- def setInputs ( # type: ignore[override]
145+ ```
146+ def setOptimizationOptions(
147+ self,
148+ optimizationOptions: str | list[str] | dict[str, Any],
149+ ) -> bool:
150+ ```
151+ """
152+ param = self ._set_compatibility_helper (pkey = 'optimizationOptions' , args = args , kwargs = kwargs )
153+ if param is None :
154+ raise ModelicaSystemError ("Invalid input for setOptimizationOptions() (v4.0.0 compatibility mode)." )
155+
156+ return super ().setOptimizationOptions (param )
157+
158+ def setInputs (
95159 self ,
96- name : str | list [str ] | dict [str , Any ],
160+ * args : Any ,
161+ ** kwargs : dict [str , Any ],
97162 ) -> bool :
98- if isinstance (name , dict ):
99- return super ().setInputs (** name )
100- raise ModelicaSystemError ("Only dict input supported for setInputs()" )
163+ """
164+ Compatibility wrapper for setInputs() from OMPython v4.0.0
165+
166+ Original definition:
101167
102- def setSimulationOptions ( # type: ignore[override]
168+ ```
169+ def setInputs(
170+ self,
171+ name: str | list[str] | dict[str, Any],
172+ ) -> bool:
173+ ```
174+ """
175+ param = self ._set_compatibility_helper (pkey = 'name' , args = args , kwargs = kwargs )
176+ if param is None :
177+ raise ModelicaSystemError ("Invalid input for setInputs() (v4.0.0 compatibility mode)." )
178+
179+ return super ().setInputs (param )
180+
181+ def setSimulationOptions (
103182 self ,
104- simOptions : str | list [str ] | dict [str , Any ],
183+ * args : Any ,
184+ ** kwargs : dict [str , Any ],
105185 ) -> bool :
106- if isinstance (simOptions , dict ):
107- return super ().setSimulationOptions (** simOptions )
108- raise ModelicaSystemError ("Only dict input supported for setSimulationOptions()" )
186+ """
187+ Compatibility wrapper for setSimulationOptions() from OMPython v4.0.0
188+
189+ Original definition:
109190
110- def setLinearizationOptions ( # type: ignore[override]
191+ ```
192+ def setSimulationOptions(
193+ self,
194+ simOptions: str | list[str] | dict[str, Any],
195+ ) -> bool:
196+ ```
197+ """
198+ param = self ._set_compatibility_helper (pkey = 'simOptions' , args = args , kwargs = kwargs )
199+ if param is None :
200+ raise ModelicaSystemError ("Invalid input for setSimulationOptions() (v4.0.0 compatibility mode)." )
201+
202+ return super ().setSimulationOptions (param )
203+
204+ def setLinearizationOptions (
111205 self ,
112- linearizationOptions : str | list [str ] | dict [str , Any ],
206+ * args : Any ,
207+ ** kwargs : dict [str , Any ],
113208 ) -> bool :
114- if isinstance (linearizationOptions , dict ):
115- return super ().setLinearizationOptions (** linearizationOptions )
116- raise ModelicaSystemError ("Only dict input supported for setLinearizationOptions()" )
209+ """
210+ Compatibility wrapper for setLinearizationOptions() from OMPython v4.0.0
211+
212+ Original definition:
213+
214+ ```
215+ def setLinearizationOptions(
216+ self,
217+ linearizationOptions: str | list[str] | dict[str, Any],
218+ ) -> bool:
219+ ```
220+ """
221+ param = self ._set_compatibility_helper (pkey = 'linearizationOptions' , args = args , kwargs = kwargs )
222+ if param is None :
223+ raise ModelicaSystemError ("Invalid input for setLinearizationOptions() (v4.0.0 compatibility mode)." )
224+
225+ return super ().setLinearizationOptions (param )
117226
118227 def getContinuous (
119228 self ,
120229 names : Optional [str | list [str ]] = None ,
121230 ):
231+ """
232+ Compatibility wrapper for getContinuous() from OMPython v4.0.0
233+
234+ If no model simulation was run (self._simulated == False), the return value should be converted to str.
235+ """
122236 retval = super ().getContinuous (names = names )
123237 if self ._simulated :
124238 return retval
@@ -146,6 +260,11 @@ def getOutputs(
146260 self ,
147261 names : Optional [str | list [str ]] = None ,
148262 ):
263+ """
264+ Compatibility wrapper for getOutputs() from OMPython v4.0.0
265+
266+ If no model simulation was run (self._simulated == False), the return value should be converted to str.
267+ """
149268 retval = super ().getOutputs (names = names )
150269 if self ._simulated :
151270 return retval
@@ -170,12 +289,14 @@ def getOutputs(
170289 raise ModelicaSystemError ("Invalid data!" )
171290
172291
292+ @depreciated_class (msg = "Please use class ModelicaDoEOMC instead!" )
173293class ModelicaSystemDoE (ModelicaDoEOMC ):
174294 """
175295 Compatibility class.
176296 """
177297
178298
299+ @depreciated_class (msg = "Please use class ModelExecutionCmd instead!" )
179300class ModelicaSystemCmd (ModelExecutionCmd ):
180301 """
181302 Compatibility class; in the new version it is renamed as ModelExecutionCmd.
0 commit comments