Skip to content

Commit 6104f06

Browse files
committed
Improve docstrings
1 parent 483b847 commit 6104f06

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def getParameters(self, names: Optional[str | list[str]] = None) -> dict[str, st
658658
raise ModelicaSystemError("Unhandled input for getParameters()")
659659

660660
def getInputs(self, names: Optional[str | list[str]] = None) -> dict | list: # 6
661-
"""Get input values.
661+
"""Get values of input signals.
662662
663663
Args:
664664
names: Either None (default), a string with the input name,
@@ -694,7 +694,7 @@ def getInputs(self, names: Optional[str | list[str]] = None) -> dict | list: #
694694
raise ModelicaSystemError("Unhandled input for getInputs()")
695695

696696
def getOutputs(self, names: Optional[str | list[str]] = None): # 7
697-
"""Get output values.
697+
"""Get values of output signals.
698698
699699
If called before simulate(), the initial values are returned as
700700
strings. If called after simulate(), the final values (at stopTime)
@@ -815,16 +815,27 @@ def getOptimizationOptions(self, names=None): # 10
815815

816816
raise ModelicaSystemError("Unhandled input for getOptimizationOptions()")
817817

818-
def simulate(self, resultfile: Optional[str] = None, simflags: Optional[str] = None,
818+
def simulate(self,
819+
resultfile: Optional[str] = None,
820+
simflags: Optional[str] = None,
819821
simargs: Optional[dict[str, Optional[str | dict[str, str]]]] = None,
820-
timeout: Optional[int] = None): # 11
821-
"""
822-
This method simulates model according to the simulation options.
823-
usage
824-
>>> simulate()
825-
>>> simulate(resultfile="a.mat")
826-
>>> simulate(simflags="-noEventEmit -noRestart -override=e=0.3,g=10") # set runtime simulation flags
827-
>>> simulate(simargs={"noEventEmit": None, "noRestart": None, "override": "e=0.3,g=10"}) # using simargs
822+
timeout: Optional[int] = None) -> None:
823+
"""Simulate the model according to simulation options.
824+
825+
See setSimulationOptions().
826+
827+
Args:
828+
resultfile: Path to a custom result file
829+
simflags: String of space separated simulation runtime flags.
830+
This argument is deprecated, use simargs instead.
831+
simargs: Dict with simulation runtime flags.
832+
timeout: Execution timeout in seconds.
833+
834+
Examples:
835+
mod.simulate()
836+
mod.simulate(resultfile="a.mat")
837+
mod.simulate(simflags="-noEventEmit -noRestart -override=e=0.3,g=10") # set runtime simulation flags, deprecated
838+
mod.simulate(simargs={"noEventEmit": None, "noRestart": None, "override": "e=0.3,g=10"}) # using simargs
828839
"""
829840

830841
om_cmd = ModelicaSystemCmd(runpath=self._tempdir, modelname=self._modelName, timeout=timeout)
@@ -943,8 +954,8 @@ def _strip_space(name):
943954
raise ModelicaSystemError("Unhandled input for strip_space()")
944955

945956
def _setMethodHelper(self, args1, args2, args3, args4=None):
946-
"""
947-
Helper function for setParameter(),setContinuous(),setSimulationOptions(),setLinearizationOption(),setOptimizationOption()
957+
"""Helper function for setters.
958+
948959
args1 - string or list of string given by user
949960
args2 - dict() containing the values of different variables(eg:, parameter,continuous,simulation parameters)
950961
args3 - function name (eg; continuous, parameter, simulation, linearization,optimization)
@@ -1211,7 +1222,7 @@ def linearize(self, lintime: Optional[float] = None, simflags: Optional[str] = N
12111222
simflags: A string of extra command line flags for the model
12121223
binary. - depreciated in favor of simargs
12131224
simargs: A dict with command line flags and possible options; example: "simargs={'csvInput': 'a.csv'}"
1214-
timeout: Possible timeout for the execution of OM.
1225+
timeout: Execution timeout in seconds.
12151226
12161227
Returns:
12171228
A LinearizationResult object is returned. This allows several
@@ -1301,13 +1312,13 @@ def load_module_from_path(module_name, file_path):
13011312
raise ModelicaSystemError("No module named 'linearized_model'") from ex
13021313

13031314
def getLinearInputs(self) -> list[str]:
1304-
"""Return names of input variables of the linearized model."""
1315+
"""Get names of input variables of the linearized model."""
13051316
return self._linearinputs
13061317

13071318
def getLinearOutputs(self) -> list[str]:
1308-
"""Return names of output variables of the linearized model."""
1319+
"""Get names of output variables of the linearized model."""
13091320
return self._linearoutputs
13101321

13111322
def getLinearStates(self) -> list[str]:
1312-
"""Return names of state variables of the linearized model."""
1323+
"""Get names of state variables of the linearized model."""
13131324
return self._linearstates

0 commit comments

Comments
 (0)