Skip to content

Commit 3202b0f

Browse files
committed
Improve ModelicaSystem.getParameters docstring
1 parent ba73cd7 commit 3202b0f

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
@@ -430,14 +430,27 @@ def getContinuous(self, names=None): # 4
430430
raise ModelicaSystemError(f"OM error: {i} is not continuous")
431431
return valuelist
432432

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

0 commit comments

Comments
 (0)