@@ -72,58 +72,167 @@ def __init__(
7272 def setCommandLineOptions (self , commandLineOptions : str ):
7373 super ().set_command_line_options (command_line_option = commandLineOptions )
7474
75- def setContinuous ( # type: ignore[override]
75+ def _set_compatibility_helper (
7676 self ,
77- cvals : str | list [str ] | dict [str , Any ],
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 (
90+ self ,
91+ * args : Any ,
92+ ** kwargs : dict [str , Any ],
7893 ) -> bool :
79- if isinstance (cvals , dict ):
80- return super ().setContinuous (** cvals )
81- raise ModelicaSystemError ("Only dict input supported for setContinuous()" )
94+ """
95+ Compatibility wrapper for setContinuous() from OMPython v4.0.0
96+
97+ Original definition:
98+
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)." )
82109
83- def setParameters ( # type: ignore[override]
110+ return super ().setContinuous (param )
111+
112+ def setParameters (
84113 self ,
85- pvals : str | list [str ] | dict [str , Any ],
114+ * args : Any ,
115+ ** kwargs : dict [str , Any ],
86116 ) -> bool :
87- if isinstance (pvals , dict ):
88- return super ().setParameters (** pvals )
89- raise ModelicaSystemError ("Only dict input supported for setParameters()" )
117+ """
118+ Compatibility wrapper for setParameters() from OMPython v4.0.0
119+
120+ Original definition:
121+
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)." )
90132
91- def setOptimizationOptions ( # type: ignore[override]
133+ return super ().setParameters (param )
134+
135+ def setOptimizationOptions (
92136 self ,
93- optimizationOptions : str | list [str ] | dict [str , Any ],
137+ * args : Any ,
138+ ** kwargs : dict [str , Any ],
94139 ) -> bool :
95- if isinstance (optimizationOptions , dict ):
96- return super ().setOptimizationOptions (** optimizationOptions )
97- raise ModelicaSystemError ("Only dict input supported for setOptimizationOptions()" )
140+ """
141+ Compatibility wrapper for setOptimizationOptions() from OMPython v4.0.0
142+
143+ Original definition:
144+
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)." )
98155
99- def setInputs ( # type: ignore[override]
156+ return super ().setOptimizationOptions (param )
157+
158+ def setInputs (
100159 self ,
101- name : str | list [str ] | dict [str , Any ],
160+ * args : Any ,
161+ ** kwargs : dict [str , Any ],
102162 ) -> bool :
103- if isinstance (name , dict ):
104- return super ().setInputs (** name )
105- raise ModelicaSystemError ("Only dict input supported for setInputs()" )
163+ """
164+ Compatibility wrapper for setInputs() from OMPython v4.0.0
106165
107- def setSimulationOptions ( # type: ignore[override]
166+ Original definition:
167+
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 (
108182 self ,
109- simOptions : str | list [str ] | dict [str , Any ],
183+ * args : Any ,
184+ ** kwargs : dict [str , Any ],
110185 ) -> bool :
111- if isinstance (simOptions , dict ):
112- return super ().setSimulationOptions (** simOptions )
113- raise ModelicaSystemError ("Only dict input supported for setSimulationOptions()" )
186+ """
187+ Compatibility wrapper for setSimulationOptions() from OMPython v4.0.0
114188
115- def setLinearizationOptions ( # type: ignore[override]
189+ Original definition:
190+
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 (
116205 self ,
117- linearizationOptions : str | list [str ] | dict [str , Any ],
206+ * args : Any ,
207+ ** kwargs : dict [str , Any ],
118208 ) -> bool :
119- if isinstance (linearizationOptions , dict ):
120- return super ().setLinearizationOptions (** linearizationOptions )
121- 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 )
122226
123227 def getContinuous (
124228 self ,
125229 names : Optional [str | list [str ]] = None ,
126230 ):
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+ """
127236 retval = super ().getContinuous (names = names )
128237 if self ._simulated :
129238 return retval
@@ -151,6 +260,11 @@ def getOutputs(
151260 self ,
152261 names : Optional [str | list [str ]] = None ,
153262 ):
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+ """
154268 retval = super ().getOutputs (names = names )
155269 if self ._simulated :
156270 return retval
0 commit comments