Skip to content

Commit a7a579b

Browse files
committed
Improve docstring for getLinearizationOptions()
1 parent d4b2af0 commit a7a579b

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -802,14 +802,31 @@ def getSimulationOptions(self, names: Optional[str | list[str]] = None) -> dict[
802802

803803
raise ModelicaSystemError("Unhandled input for getSimulationOptions()")
804804

805-
def getLinearizationOptions(self, names=None): # 9
806-
"""
807-
This method returns dict. The key is linearize option names and value is corresponding linearize option value.
808-
If name is None then the function will return dict which contain all linearize option names as key and value as corresponding values. eg., getLinearizationOptions()
809-
usage:
810-
>>> getLinearizationOptions()
811-
>>> getLinearizationOptions("Name1")
812-
>>> getLinearizationOptions(["Name1","Name2"])
805+
def getLinearizationOptions(self, names: Optional[str | list[str]] = None) -> dict | list:
806+
"""Get simulation options used for linearization.
807+
808+
Args:
809+
names: Either None (default), a string with the linearization option
810+
name, or a list of option name strings.
811+
812+
Returns:
813+
If `names` is None, a dict in the format
814+
{option_name: option_value} is returned.
815+
If `names` is a string, a single element list [option_value] is
816+
returned.
817+
If `names` is a list, a list with one value for each option name
818+
in names is returned: [option1_value, option2_value, ...].
819+
Some option values are returned as float when first initialized,
820+
but always as strings after setLinearizationOptions is used to
821+
change them.
822+
823+
Examples:
824+
>>> mod.getLinearizationOptions()
825+
{'startTime': 0.0, 'stopTime': 1.0, 'stepSize': 0.002, 'tolerance': 1e-08}
826+
>>> mod.getLinearizationOptions("stopTime")
827+
[1.0]
828+
>>> mod.getLinearizationOptions(["tolerance", "stopTime"])
829+
[1e-08, 1.0]
813830
"""
814831
if names is None:
815832
return self._linearOptions

0 commit comments

Comments
 (0)