Skip to content

Commit e148d37

Browse files
committed
[ModelicaSystemCmd] remove depreciated simflags
1 parent 0c03bf5 commit e148d37

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
"""
@@ -1052,7 +1014,6 @@ def getOptimizationOptions(
10521014
def simulate_cmd(
10531015
self,
10541016
result_file: OMCPath,
1055-
simflags: Optional[str] = None,
10561017
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
10571018
timeout: Optional[float] = None,
10581019
) -> ModelicaSystemCmd:
@@ -1066,13 +1027,6 @@ def simulate_cmd(
10661027
However, if only non-structural parameters are used, it is possible to reuse an existing instance of
10671028
ModelicaSystem to create several version ModelicaSystemCmd to run the model using different settings.
10681029
1069-
Parameters
1070-
----------
1071-
result_file
1072-
simflags
1073-
simargs
1074-
timeout
1075-
10761030
Returns
10771031
-------
10781032
An instance if ModelicaSystemCmd to run the requested simulation.
@@ -1088,11 +1042,7 @@ def simulate_cmd(
10881042
# always define the result file to use
10891043
om_cmd.arg_set(key="r", val=result_file.as_posix())
10901044

1091-
# allow runtime simulation flags from user input
1092-
if simflags is not None:
1093-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1094-
1095-
if simargs:
1045+
if simargs is not None:
10961046
om_cmd.args_set(args=simargs)
10971047

10981048
if self._override_variables or self._simulate_options_override:
@@ -1130,7 +1080,6 @@ def simulate_cmd(
11301080
def simulate(
11311081
self,
11321082
resultfile: Optional[str | os.PathLike] = None,
1133-
simflags: Optional[str] = None,
11341083
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
11351084
timeout: Optional[float] = None,
11361085
) -> None:
@@ -1140,8 +1089,6 @@ def simulate(
11401089
11411090
Args:
11421091
resultfile: Path to a custom result file
1143-
simflags: String of extra command line flags for the model binary.
1144-
This argument is deprecated, use simargs instead.
11451092
simargs: Dict with simulation runtime flags.
11461093
timeout: Maximum execution time in seconds.
11471094
@@ -1169,7 +1116,6 @@ def simulate(
11691116

11701117
om_cmd = self.simulate_cmd(
11711118
result_file=self._result_file,
1172-
simflags=simflags,
11731119
simargs=simargs,
11741120
timeout=timeout,
11751121
)
@@ -1752,7 +1698,6 @@ def optimize(self) -> dict[str, Any]:
17521698
def linearize(
17531699
self,
17541700
lintime: Optional[float] = None,
1755-
simflags: Optional[str] = None,
17561701
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
17571702
timeout: Optional[float] = None,
17581703
) -> LinearizationResult:
@@ -1762,8 +1707,6 @@ def linearize(
17621707
17631708
Args:
17641709
lintime: Override "stopTime" value.
1765-
simflags: String of extra command line flags for the model binary.
1766-
This argument is deprecated, use simargs instead.
17671710
simargs: A dict with command line flags and possible options; example: "simargs={'csvInput': 'a.csv'}"
17681711
timeout: Maximum execution time in seconds.
17691712
@@ -1811,11 +1754,7 @@ def linearize(
18111754

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

1814-
# allow runtime simulation flags from user input
1815-
if simflags is not None:
1816-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1817-
1818-
if simargs:
1757+
if simargs is not None:
18191758
om_cmd.args_set(args=simargs)
18201759

18211760
# 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)