Skip to content

Commit 2b10ccf

Browse files
committed
Merge branch 'remove_depreciated_functionality' into v5.0.0-status20260123
2 parents 6d50af7 + 035a549 commit 2b10ccf

4 files changed

Lines changed: 6 additions & 85 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -255,46 +255,6 @@ def definition(self) -> OMCSessionRunData:
255255

256256
return omc_run_data_updated
257257

258-
@staticmethod
259-
def parse_simflags(simflags: str) -> dict[str, Optional[str | dict[str, Any] | numbers.Number]]:
260-
"""
261-
Parse a simflag definition; this is deprecated!
262-
263-
The return data can be used as input for self.args_set().
264-
"""
265-
warnings.warn(message="The argument 'simflags' is depreciated and will be removed in future versions; "
266-
"please use 'simargs' instead",
267-
category=DeprecationWarning,
268-
stacklevel=2)
269-
270-
simargs: dict[str, Optional[str | dict[str, Any] | numbers.Number]] = {}
271-
272-
args = [s for s in simflags.split(' ') if s]
273-
for arg in args:
274-
if arg[0] != '-':
275-
raise ModelicaSystemError(f"Invalid simulation flag: {arg}")
276-
arg = arg[1:]
277-
parts = arg.split('=')
278-
if len(parts) == 1:
279-
simargs[parts[0]] = None
280-
elif parts[0] == 'override':
281-
override = '='.join(parts[1:])
282-
283-
override_dict = {}
284-
for item in override.split(','):
285-
kv = item.split('=')
286-
if not 0 < len(kv) < 3:
287-
raise ModelicaSystemError(f"Invalid value for '-override': {override}")
288-
if kv[0]:
289-
try:
290-
override_dict[kv[0]] = kv[1]
291-
except (KeyError, IndexError) as ex:
292-
raise ModelicaSystemError(f"Invalid value for '-override': {override}") from ex
293-
294-
simargs[parts[0]] = override_dict
295-
296-
return simargs
297-
298258

299259
class ModelicaSystem:
300260
"""
@@ -1067,7 +1027,6 @@ def _process_override_data(
10671027
def simulate_cmd(
10681028
self,
10691029
result_file: OMCPath,
1070-
simflags: Optional[str] = None,
10711030
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
10721031
) -> ModelicaSystemCmd:
10731032
"""
@@ -1080,12 +1039,6 @@ def simulate_cmd(
10801039
However, if only non-structural parameters are used, it is possible to reuse an existing instance of
10811040
ModelicaSystem to create several version ModelicaSystemCmd to run the model using different settings.
10821041
1083-
Parameters
1084-
----------
1085-
result_file
1086-
simflags
1087-
simargs
1088-
10891042
Returns
10901043
-------
10911044
An instance if ModelicaSystemCmd to run the requested simulation.
@@ -1100,11 +1053,7 @@ def simulate_cmd(
11001053
# always define the result file to use
11011054
om_cmd.arg_set(key="r", val=result_file.as_posix())
11021055

1103-
# allow runtime simulation flags from user input
1104-
if simflags is not None:
1105-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1106-
1107-
if simargs:
1056+
if simargs is not None:
11081057
om_cmd.args_set(args=simargs)
11091058

11101059
self._process_override_data(
@@ -1137,7 +1086,6 @@ def simulate_cmd(
11371086
def simulate(
11381087
self,
11391088
resultfile: Optional[str | os.PathLike] = None,
1140-
simflags: Optional[str] = None,
11411089
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
11421090
) -> None:
11431091
"""Simulate the model according to simulation options.
@@ -1146,8 +1094,6 @@ def simulate(
11461094
11471095
Args:
11481096
resultfile: Path to a custom result file
1149-
simflags: String of extra command line flags for the model binary.
1150-
This argument is deprecated, use simargs instead.
11511097
simargs: Dict with simulation runtime flags.
11521098
11531099
Examples:
@@ -1174,7 +1120,6 @@ def simulate(
11741120

11751121
om_cmd = self.simulate_cmd(
11761122
result_file=self._result_file,
1177-
simflags=simflags,
11781123
simargs=simargs,
11791124
)
11801125

@@ -1686,7 +1631,6 @@ def optimize(self) -> dict[str, Any]:
16861631
def linearize(
16871632
self,
16881633
lintime: Optional[float] = None,
1689-
simflags: Optional[str] = None,
16901634
simargs: Optional[dict[str, Optional[str | dict[str, Any] | numbers.Number]]] = None,
16911635
) -> LinearizationResult:
16921636
"""Linearize the model according to linearization options.
@@ -1695,8 +1639,6 @@ def linearize(
16951639
16961640
Args:
16971641
lintime: Override "stopTime" value.
1698-
simflags: String of extra command line flags for the model binary.
1699-
This argument is deprecated, use simargs instead.
17001642
simargs: A dict with command line flags and possible options; example: "simargs={'csvInput': 'a.csv'}"
17011643
17021644
Returns:
@@ -1746,11 +1688,7 @@ def linearize(
17461688
f"<= lintime <= {self._linearization_options['stopTime']}")
17471689
om_cmd.arg_set(key="l", val=str(lintime))
17481690

1749-
# allow runtime simulation flags from user input
1750-
if simflags is not None:
1751-
om_cmd.args_set(args=om_cmd.parse_simflags(simflags=simflags))
1752-
1753-
if simargs:
1691+
if simargs is not None:
17541692
om_cmd.args_set(args=simargs)
17551693

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

OMPython/OMCSession.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,6 @@ def run_model_executable(self, cmd_run_data: OMCSessionRunData) -> int:
520520
"""
521521
return self.omc_process.run_model_executable(cmd_run_data=cmd_run_data)
522522

523-
def execute(self, command: str):
524-
return self.omc_process.execute(command=command)
525-
526523
def sendExpression(self, command: str, parsed: bool = True) -> Any:
527524
"""
528525
Send an expression to the OMC server and return the result.
@@ -796,14 +793,6 @@ def run_model_executable(self, cmd_run_data: OMCSessionRunData) -> int:
796793

797794
return returncode
798795

799-
def execute(self, command: str):
800-
warnings.warn(message="This function is depreciated and will be removed in future versions; "
801-
"please use sendExpression() instead",
802-
category=DeprecationWarning,
803-
stacklevel=2)
804-
805-
return self.sendExpression(command, parsed=False)
806-
807796
def sendExpression(self, expr: str, parsed: bool = True) -> Any:
808797
"""
809798
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: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ 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'
40+
def test_sendExpression(omcs):
4341
assert omcs.sendExpression('"HelloWorld!"', parsed=False) == '"HelloWorld!"\n'
4442
assert omcs.sendExpression('"HelloWorld!"', parsed=True) == 'HelloWorld!'
4543

0 commit comments

Comments
 (0)