Skip to content

Commit b746a39

Browse files
committed
Improve ModelicaSystem.getParameters docstring
1 parent 19472b3 commit b746a39

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,27 @@ def getContinuous(self, names=None): # 4
429429
raise ModelicaSystemError(f"OM error: {i} is not continuous")
430430
return valuelist
431431

432-
def getParameters(self, names=None): # 5
433-
"""
434-
This method returns dict. The key is parameter names and value is corresponding parameter value.
435-
If name is None then the function will return dict which contain all parameter names as key and value as corresponding values.
436-
usage:
437-
>>> getParameters()
438-
>>> getParameters("Name1")
439-
>>> getParameters(["Name1","Name2"])
432+
def getParameters(self, names: Optional[str | list[str]] = None) -> dict[str, str] | list[str]: # 5
433+
"""Get parameter values.
434+
435+
Args:
436+
names: Either None (default), a string with the parameter name,
437+
or a list of parameter name strings.
438+
Returns:
439+
If `names` is None, a dict in the format
440+
{parameter_name: parameter_value} is returned.
441+
If `names` is a string, a single element list is returned.
442+
If `names` is a list, a list with one value for each parameter name
443+
in names is returned.
444+
In all cases, parameter values are returned as strings.
445+
446+
Examples:
447+
>>> mod.getParameters()
448+
{'Name1': '1.23', 'Name2': '4.56'}
449+
>>> mod.getParameters("Name1")
450+
['1.23']
451+
>>> mod.getParameters(["Name1","Name2"])
452+
['1.23', '4.56']
440453
"""
441454
if names is None:
442455
return self.paramlist

0 commit comments

Comments
 (0)