Skip to content

Commit 870e597

Browse files
committed
Improve ModelicaSystem.getParameters docstring
1 parent c7b27b0 commit 870e597

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

485-
def getParameters(self, names=None): # 5
486-
"""
487-
This method returns dict. The key is parameter names and value is corresponding parameter value.
488-
If name is None then the function will return dict which contain all parameter names as key and value as corresponding values.
489-
usage:
490-
>>> getParameters()
491-
>>> getParameters("Name1")
492-
>>> getParameters(["Name1","Name2"])
485+
def getParameters(self, names: Optional[str | list[str]] = None) -> dict[str, str] | list[str]: # 5
486+
"""Get parameter values.
487+
488+
Args:
489+
names: Either None (default), a string with the parameter name,
490+
or a list of parameter name strings.
491+
Returns:
492+
If `names` is None, a dict in the format
493+
{parameter_name: parameter_value} is returned.
494+
If `names` is a string, a single element list is returned.
495+
If `names` is a list, a list with one value for each parameter name
496+
in names is returned.
497+
In all cases, parameter values are returned as strings.
498+
499+
Examples:
500+
>>> mod.getParameters()
501+
{'Name1': '1.23', 'Name2': '4.56'}
502+
>>> mod.getParameters("Name1")
503+
['1.23']
504+
>>> mod.getParameters(["Name1","Name2"])
505+
['1.23', '4.56']
493506
"""
494507
if names is None:
495508
return self.paramlist

0 commit comments

Comments
 (0)