Skip to content

Commit 8eb2dd8

Browse files
committed
Merge branch 'remove_depreciated_functionality' into v5.0.0-syntron
2 parents ef68951 + 7cd44f1 commit 8eb2dd8

4 files changed

Lines changed: 3 additions & 75 deletions

File tree

OMPython/ModelicaSystem.py

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

283283
return omc_run_data_updated
284284

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

324286
class ModelicaSystem:
325287
def __init__(
@@ -1003,7 +965,6 @@ def getOptimizationOptions(self, names: Optional[str | list[str]] = None) -> dic
1003965
def simulate_cmd(
1004966
self,
1005967
result_file: OMCPath,
1006-
simflags: Optional[str] = None,
1007968
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
1008969
timeout: Optional[float] = None,
1009970
) -> ModelicaSystemCmd:
@@ -1017,13 +978,6 @@ def simulate_cmd(
1017978
However, if only non-structural parameters are used, it is possible to reuse an existing instance of
1018979
ModelicaSystem to create several version ModelicaSystemCmd to run the model using different settings.
1019980
1020-
Parameters
1021-
----------
1022-
result_file
1023-
simflags
1024-
simargs
1025-
timeout
1026-
1027981
Returns
1028982
-------
1029983
An instance if ModelicaSystemCmd to run the requested simulation.
@@ -1039,11 +993,7 @@ def simulate_cmd(
1039993
# always define the result file to use
1040994
om_cmd.arg_set(key="r", val=result_file.as_posix())
1041995

1042-
# allow runtime simulation flags from user input
1043-
if simflags is not None:
1044-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1045-
1046-
if simargs:
996+
if simargs is not None:
1047997
om_cmd.args_set(args=simargs)
1048998

1049999
if self._override_variables or self._simulate_options_override:
@@ -1082,7 +1032,6 @@ def simulate_cmd(
10821032
def simulate(
10831033
self,
10841034
resultfile: Optional[str] = None,
1085-
simflags: Optional[str] = None,
10861035
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
10871036
timeout: Optional[float] = None,
10881037
) -> None:
@@ -1092,8 +1041,6 @@ def simulate(
10921041
10931042
Args:
10941043
resultfile: Path to a custom result file
1095-
simflags: String of extra command line flags for the model binary.
1096-
This argument is deprecated, use simargs instead.
10971044
simargs: Dict with simulation runtime flags.
10981045
timeout: Maximum execution time in seconds.
10991046
@@ -1121,7 +1068,6 @@ def simulate(
11211068

11221069
om_cmd = self.simulate_cmd(
11231070
result_file=self._result_file,
1124-
simflags=simflags,
11251071
simargs=simargs,
11261072
timeout=timeout,
11271073
)
@@ -1700,7 +1646,6 @@ def optimize(self) -> dict[str, Any]:
17001646
def linearize(
17011647
self,
17021648
lintime: Optional[float] = None,
1703-
simflags: Optional[str] = None,
17041649
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
17051650
timeout: Optional[float] = None,
17061651
) -> LinearizationResult:
@@ -1710,8 +1655,6 @@ def linearize(
17101655
17111656
Args:
17121657
lintime: Override "stopTime" value.
1713-
simflags: String of extra command line flags for the model binary.
1714-
This argument is deprecated, use simargs instead.
17151658
simargs: A dict with command line flags and possible options; example: "simargs={'csvInput': 'a.csv'}"
17161659
timeout: Maximum execution time in seconds.
17171660
@@ -1760,11 +1703,7 @@ def linearize(
17601703

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

1763-
# allow runtime simulation flags from user input
1764-
if simflags is not None:
1765-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1766-
1767-
if simargs:
1706+
if simargs is not None:
17681707
om_cmd.args_set(args=simargs)
17691708

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

OMPython/OMCSession.py

Lines changed: 0 additions & 7 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
@@ -595,12 +594,6 @@ def run_model_executable(cmd_run_data: OMCSessionRunData) -> int:
595594

596595
return returncode
597596

598-
def execute(self, command: str):
599-
warnings.warn("This function is depreciated and will be removed in future versions; "
600-
"please use sendExpression() instead", DeprecationWarning, stacklevel=2)
601-
602-
return self.sendExpression(command, parsed=False)
603-
604597
def sendExpression(self, command: str, parsed: bool = True) -> Any:
605598
"""
606599
Send an expression to the OMC server and return the result.

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',

tests/test_ZMQ.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def test_Simulate(om, model_time_str):
3636
assert om.sendExpression('res.resultFile')
3737

3838

39-
def test_execute(om):
40-
with pytest.deprecated_call():
41-
assert om.execute('"HelloWorld!"') == '"HelloWorld!"\n'
39+
def test_sendExpression(om):
4240
assert om.sendExpression('"HelloWorld!"', parsed=False) == '"HelloWorld!"\n'
4341
assert om.sendExpression('"HelloWorld!"', parsed=True) == 'HelloWorld!'
4442

0 commit comments

Comments
 (0)