Skip to content

Commit d4b2af0

Browse files
committed
Improve docstring for getSimulationOptions()
1 parent 214c657 commit d4b2af0

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -769,14 +769,29 @@ def getOutputs(self, names: Optional[str | list[str]] = None): # 7
769769

770770
raise ModelicaSystemError("Unhandled input for getOutputs()")
771771

772-
def getSimulationOptions(self, names=None): # 8
773-
"""
774-
This method returns dict. The key is simulation option names and value is corresponding simulation option value.
775-
If name is None then the function will return dict which contain all simulation option names as key and value as corresponding values. eg., getSimulationOptions()
776-
usage:
777-
>>> getSimulationOptions()
778-
>>> getSimulationOptions("Name1")
779-
>>> getSimulationOptions(["Name1","Name2"])
772+
def getSimulationOptions(self, names: Optional[str | list[str]] = None) -> dict[str, str] | list[str]:
773+
"""Get simulation options such as stopTime and tolerance.
774+
775+
Args:
776+
names: Either None (default), a string with the simulation option
777+
name, or a list of option name strings.
778+
779+
Returns:
780+
If `names` is None, a dict in the format
781+
{option_name: option_value} is returned.
782+
If `names` is a string, a single element list [option_value] is
783+
returned.
784+
If `names` is a list, a list with one value for each option name
785+
in names is returned: [option1_value, option2_value, ...].
786+
Option values are always returned as strings.
787+
788+
Examples:
789+
>>> mod.getSimulationOptions()
790+
{'startTime': '0', 'stopTime': '1.234', 'stepSize': '0.002', 'tolerance': '1.1e-08', 'solver': 'dassl', 'outputFormat': 'mat'}
791+
>>> mod.getSimulationOptions("stopTime")
792+
['1.234']
793+
>>> mod.getSimulationOptions(["tolerance", "stopTime"])
794+
['1.1e-08', '1.234']
780795
"""
781796
if names is None:
782797
return self._simulateOptions

0 commit comments

Comments
 (0)