Skip to content

Commit 3bd069a

Browse files
committed
Improve docstring for getOptimizationOptions()
1 parent 48d06be commit 3bd069a

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -871,12 +871,31 @@ def getLinearizationOptions(self, names: Optional[str | list[str]] = None) -> di
871871

872872
raise ModelicaSystemError("Unhandled input for getLinearizationOptions()")
873873

874-
def getOptimizationOptions(self, names=None): # 10
875-
"""
876-
usage:
877-
>>> getOptimizationOptions()
878-
>>> getOptimizationOptions("Name1")
879-
>>> getOptimizationOptions(["Name1","Name2"])
874+
def getOptimizationOptions(self, names: Optional[str | list[str]] = None) -> dict | list:
875+
"""Get simulation options used for optimization.
876+
877+
Args:
878+
names: Either None (default), a string with the optimization option
879+
name, or a list of option name strings.
880+
881+
Returns:
882+
If `names` is None, a dict in the format
883+
{option_name: option_value} is returned.
884+
If `names` is a string, a single element list [option_value] is
885+
returned.
886+
If `names` is a list, a list with one value for each option name
887+
in names is returned: [option1_value, option2_value, ...].
888+
Some option values are returned as float when first initialized,
889+
but always as strings after setOptimizationOptions is used to
890+
change them.
891+
892+
Examples:
893+
>>> mod.getOptimizationOptions()
894+
{'startTime': 0.0, 'stopTime': 1.0, 'numberOfIntervals': 500, 'stepSize': 0.002, 'tolerance': 1e-08}
895+
>>> mod.getOptimizationOptions("stopTime")
896+
[1.0]
897+
>>> mod.getOptimizationOptions(["tolerance", "stopTime"])
898+
[1e-08, 1.0]
880899
"""
881900
if names is None:
882901
return self._optimizeOptions

0 commit comments

Comments
 (0)