Skip to content

Commit af7a41c

Browse files
committed
[ModelicaSystemCmd] remove depreciated simflags
1 parent 827192b commit af7a41c

2 files changed

Lines changed: 2 additions & 65 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -283,44 +283,6 @@ def definition(self) -> OMCSessionRunData:
283283

284284
return omc_run_data_updated
285285

286-
@staticmethod
287-
def parse_simflags(simflags: str) -> dict[str, Optional[str | dict[str, Any] | numbers.Number]]:
288-
"""
289-
Parse a simflag definition; this is deprecated!
290-
291-
The return data can be used as input for self.args_set().
292-
"""
293-
warnings.warn("The argument 'simflags' is depreciated and will be removed in future versions; "
294-
"please use 'simargs' instead", DeprecationWarning, stacklevel=2)
295-
296-
simargs: dict[str, Optional[str | dict[str, Any] | numbers.Number]] = {}
297-
298-
args = [s for s in simflags.split(' ') if s]
299-
for arg in args:
300-
if arg[0] != '-':
301-
raise ModelicaSystemError(f"Invalid simulation flag: {arg}")
302-
arg = arg[1:]
303-
parts = arg.split('=')
304-
if len(parts) == 1:
305-
simargs[parts[0]] = None
306-
elif parts[0] == 'override':
307-
override = '='.join(parts[1:])
308-
309-
override_dict = {}
310-
for item in override.split(','):
311-
kv = item.split('=')
312-
if not 0 < len(kv) < 3:
313-
raise ModelicaSystemError(f"Invalid value for '-override': {override}")
314-
if kv[0]:
315-
try:
316-
override_dict[kv[0]] = kv[1]
317-
except (KeyError, IndexError) as ex:
318-
raise ModelicaSystemError(f"Invalid value for '-override': {override}") from ex
319-
320-
simargs[parts[0]] = override_dict
321-
322-
return simargs
323-
324286

325287
class ModelicaSystem:
326288
"""
@@ -1024,7 +986,6 @@ def getOptimizationOptions(self, names: Optional[str | list[str]] = None) -> dic
1024986
def simulate_cmd(
1025987
self,
1026988
result_file: OMCPath,
1027-
simflags: Optional[str] = None,
1028989
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
1029990
timeout: Optional[float] = None,
1030991
) -> ModelicaSystemCmd:
@@ -1038,13 +999,6 @@ def simulate_cmd(
1038999
However, if only non-structural parameters are used, it is possible to reuse an existing instance of
10391000
ModelicaSystem to create several version ModelicaSystemCmd to run the model using different settings.
10401001
1041-
Parameters
1042-
----------
1043-
result_file
1044-
simflags
1045-
simargs
1046-
timeout
1047-
10481002
Returns
10491003
-------
10501004
An instance if ModelicaSystemCmd to run the requested simulation.
@@ -1060,11 +1014,7 @@ def simulate_cmd(
10601014
# always define the result file to use
10611015
om_cmd.arg_set(key="r", val=result_file.as_posix())
10621016

1063-
# allow runtime simulation flags from user input
1064-
if simflags is not None:
1065-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1066-
1067-
if simargs:
1017+
if simargs is not None:
10681018
om_cmd.args_set(args=simargs)
10691019

10701020
if self._override_variables or self._simulate_options_override:
@@ -1102,7 +1052,6 @@ def simulate_cmd(
11021052
def simulate(
11031053
self,
11041054
resultfile: Optional[str] = None,
1105-
simflags: Optional[str] = None,
11061055
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
11071056
timeout: Optional[float] = None,
11081057
) -> None:
@@ -1112,8 +1061,6 @@ def simulate(
11121061
11131062
Args:
11141063
resultfile: Path to a custom result file
1115-
simflags: String of extra command line flags for the model binary.
1116-
This argument is deprecated, use simargs instead.
11171064
simargs: Dict with simulation runtime flags.
11181065
timeout: Maximum execution time in seconds.
11191066
@@ -1141,7 +1088,6 @@ def simulate(
11411088

11421089
om_cmd = self.simulate_cmd(
11431090
result_file=self._result_file,
1144-
simflags=simflags,
11451091
simargs=simargs,
11461092
timeout=timeout,
11471093
)
@@ -1723,7 +1669,6 @@ def optimize(self) -> dict[str, Any]:
17231669
def linearize(
17241670
self,
17251671
lintime: Optional[float] = None,
1726-
simflags: Optional[str] = None,
17271672
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
17281673
timeout: Optional[float] = None,
17291674
) -> LinearizationResult:
@@ -1733,8 +1678,6 @@ def linearize(
17331678
17341679
Args:
17351680
lintime: Override "stopTime" value.
1736-
simflags: String of extra command line flags for the model binary.
1737-
This argument is deprecated, use simargs instead.
17381681
simargs: A dict with command line flags and possible options; example: "simargs={'csvInput': 'a.csv'}"
17391682
timeout: Maximum execution time in seconds.
17401683
@@ -1782,11 +1725,7 @@ def linearize(
17821725

17831726
om_cmd.arg_set(key="l", val=str(lintime or self._linearization_options["stopTime"]))
17841727

1785-
# allow runtime simulation flags from user input
1786-
if simflags is not None:
1787-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1788-
1789-
if simargs:
1728+
if simargs is not None:
17901729
om_cmd.args_set(args=simargs)
17911730

17921731
# the file create by the model executable which contains the matrix and linear inputs, outputs and states

tests/test_ModelicaSystemCmd.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ def test_simflags(mscmd_firstorder):
3737
"noEventEmit": None,
3838
"override": {'b': 2}
3939
})
40-
with pytest.deprecated_call():
41-
mscmd.args_set(args=mscmd.parse_simflags(simflags="-noEventEmit -noRestart -override=a=1,x=3"))
4240

4341
assert mscmd.get_cmd_args() == [
4442
'-noEventEmit',

0 commit comments

Comments
 (0)