Skip to content

Commit 6837ed4

Browse files
committed
Merge branch 'remove_depreciated_functionality' into v5.0.0-syntron
2 parents d48fd25 + 30c29b8 commit 6837ed4

4 files changed

Lines changed: 8 additions & 85 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -283,46 +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(message="The argument 'simflags' is depreciated and will be removed in future versions; "
294-
"please use 'simargs' instead",
295-
category=DeprecationWarning,
296-
stacklevel=2)
297-
298-
simargs: dict[str, Optional[str | dict[str, Any] | numbers.Number]] = {}
299-
300-
args = [s for s in simflags.split(' ') if s]
301-
for arg in args:
302-
if arg[0] != '-':
303-
raise ModelicaSystemError(f"Invalid simulation flag: {arg}")
304-
arg = arg[1:]
305-
parts = arg.split('=')
306-
if len(parts) == 1:
307-
simargs[parts[0]] = None
308-
elif parts[0] == 'override':
309-
override = '='.join(parts[1:])
310-
311-
override_dict = {}
312-
for item in override.split(','):
313-
kv = item.split('=')
314-
if not 0 < len(kv) < 3:
315-
raise ModelicaSystemError(f"Invalid value for '-override': {override}")
316-
if kv[0]:
317-
try:
318-
override_dict[kv[0]] = kv[1]
319-
except (KeyError, IndexError) as ex:
320-
raise ModelicaSystemError(f"Invalid value for '-override': {override}") from ex
321-
322-
simargs[parts[0]] = override_dict
323-
324-
return simargs
325-
326286

327287
class ModelicaSystem:
328288
"""
@@ -1053,7 +1013,6 @@ def getOptimizationOptions(
10531013
def simulate_cmd(
10541014
self,
10551015
result_file: OMCPath,
1056-
simflags: Optional[str] = None,
10571016
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
10581017
) -> ModelicaSystemCmd:
10591018
"""
@@ -1066,12 +1025,6 @@ def simulate_cmd(
10661025
However, if only non-structural parameters are used, it is possible to reuse an existing instance of
10671026
ModelicaSystem to create several version ModelicaSystemCmd to run the model using different settings.
10681027
1069-
Parameters
1070-
----------
1071-
result_file
1072-
simflags
1073-
simargs
1074-
10751028
Returns
10761029
-------
10771030
An instance if ModelicaSystemCmd to run the requested simulation.
@@ -1086,11 +1039,7 @@ def simulate_cmd(
10861039
# always define the result file to use
10871040
om_cmd.arg_set(key="r", val=result_file.as_posix())
10881041

1089-
# allow runtime simulation flags from user input
1090-
if simflags is not None:
1091-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1092-
1093-
if simargs:
1042+
if simargs is not None:
10941043
om_cmd.args_set(args=simargs)
10951044

10961045
if self._override_variables or self._simulate_options_override:
@@ -1128,7 +1077,6 @@ def simulate_cmd(
11281077
def simulate(
11291078
self,
11301079
resultfile: Optional[str | os.PathLike] = None,
1131-
simflags: Optional[str] = None,
11321080
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
11331081
) -> None:
11341082
"""Simulate the model according to simulation options.
@@ -1137,8 +1085,6 @@ def simulate(
11371085
11381086
Args:
11391087
resultfile: Path to a custom result file
1140-
simflags: String of extra command line flags for the model binary.
1141-
This argument is deprecated, use simargs instead.
11421088
simargs: Dict with simulation runtime flags.
11431089
11441090
Examples:
@@ -1165,7 +1111,6 @@ def simulate(
11651111

11661112
om_cmd = self.simulate_cmd(
11671113
result_file=self._result_file,
1168-
simflags=simflags,
11691114
simargs=simargs,
11701115
)
11711116

@@ -1677,7 +1622,6 @@ def optimize(self) -> dict[str, Any]:
16771622
def linearize(
16781623
self,
16791624
lintime: Optional[float] = None,
1680-
simflags: Optional[str] = None,
16811625
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
16821626
) -> LinearizationResult:
16831627
"""Linearize the model according to linearization options.
@@ -1686,8 +1630,6 @@ def linearize(
16861630
16871631
Args:
16881632
lintime: Override "stopTime" value.
1689-
simflags: String of extra command line flags for the model binary.
1690-
This argument is deprecated, use simargs instead.
16911633
simargs: A dict with command line flags and possible options; example: "simargs={'csvInput': 'a.csv'}"
16921634
16931635
Returns:
@@ -1733,11 +1675,7 @@ def linearize(
17331675

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

1736-
# allow runtime simulation flags from user input
1737-
if simflags is not None:
1738-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1739-
1740-
if simargs:
1678+
if simargs is not None:
17411679
om_cmd.args_set(args=simargs)
17421680

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

OMPython/OMCSession.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import time
5252
from typing import Any, Optional, Tuple
5353
import uuid
54-
import warnings
5554
import zmq
5655

5756
import psutil
@@ -752,14 +751,6 @@ def run_model_executable(self, cmd_run_data: OMCSessionRunData) -> int:
752751

753752
return returncode
754753

755-
def execute(self, command: str):
756-
warnings.warn(message="This function is depreciated and will be removed in future versions; "
757-
"please use sendExpression() instead",
758-
category=DeprecationWarning,
759-
stacklevel=2)
760-
761-
return self.sendExpression(command, parsed=False)
762-
763754
def sendExpression(self, command: str, parsed: bool = True) -> Any:
764755
"""
765756
Send an expression to the OMC server and return the result.

tests/test_ModelicaSystemCmd.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ def test_simflags(mscmd_firstorder):
3636

3737
mscmd.args_set({
3838
"noEventEmit": None,
39-
"override": {'b': 2}
39+
"override": {'b': 2, 'a': 4},
4040
})
41-
with pytest.deprecated_call():
42-
mscmd.args_set(args=mscmd.parse_simflags(simflags="-noEventEmit -noRestart -override=a=1,x=3"))
4341

4442
assert mscmd.get_cmd_args() == [
4543
'-noEventEmit',
46-
'-noRestart',
47-
'-override=a=1,b=2,x=3',
44+
'-override=a=4,b=2',
4845
]
4946

5047
mscmd.args_set({
@@ -53,6 +50,5 @@ def test_simflags(mscmd_firstorder):
5350

5451
assert mscmd.get_cmd_args() == [
5552
'-noEventEmit',
56-
'-noRestart',
57-
'-override=a=1,x=3',
53+
'-override=a=4',
5854
]

tests/test_ZMQ.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ def test_Simulate(omcs, model_time_str):
3737
assert omcs.sendExpression('res.resultFile')
3838

3939

40-
def test_execute(omcs):
41-
with pytest.deprecated_call():
42-
assert omcs.execute('"HelloWorld!"') == '"HelloWorld!"\n'
43-
assert omcs.sendExpression('"HelloWorld!"', parsed=False) == '"HelloWorld!"\n'
44-
assert omcs.sendExpression('"HelloWorld!"', parsed=True) == 'HelloWorld!'
40+
def test_sendExpression(om):
41+
assert om.sendExpression('"HelloWorld!"', parsed=False) == '"HelloWorld!"\n'
42+
assert om.sendExpression('"HelloWorld!"', parsed=True) == 'HelloWorld!'
4543

4644

4745
def test_omcprocessport_execute(omcs):

0 commit comments

Comments
 (0)