Skip to content

Commit 8dec408

Browse files
committed
Improve getInputs docstring
1 parent 870e597 commit 8dec408

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,32 @@ def getParameters(self, names: Optional[str | list[str]] = None) -> dict[str, st
511511
elif isinstance(names, list):
512512
return ([self.paramlist.get(x, "NotExist") for x in names])
513513

514-
def getInputs(self, names=None): # 6
515-
"""
516-
This method returns dict. The key is input names and value is corresponding input value.
517-
If *name is None then the function will return dict which contain all input names as key and value as corresponding values. eg., getInputs()
518-
Otherwise variable number of arguments can be passed as input name in string format separated by commas. eg., getInputs('iName1', 'iName2')
514+
def getInputs(self, names: Optional[str | list[str]] = None) -> dict | list: # 6
515+
"""Get input values.
516+
517+
Args:
518+
names: Either None (default), a string with the input name,
519+
or a list of input name strings.
520+
Returns:
521+
If `names` is None, a dict in the format
522+
{input_name: input_value} is returned.
523+
If `names` is a string, a single element list [input_value] is
524+
returned.
525+
If `names` is a list, a list with one value for each input name
526+
in names is returned: [input1_values, input2_values, ...].
527+
In all cases, input values are returned as a list of tuples,
528+
where the first element in the tuple is the time and the second
529+
element is the input value.
530+
531+
Examples:
532+
>>> mod.getInputs()
533+
{'Name1': [(0.0, 0.0), (1.0, 1.0)], 'Name2': None}
534+
>>> mod.getInputs("Name1")
535+
[[(0.0, 0.0), (1.0, 1.0)]]
536+
>>> mod.getInputs(["Name1","Name2"])
537+
[[(0.0, 0.0), (1.0, 1.0)], None]
538+
>>> mod.getInputs("ThisInputDoesNotExist")
539+
['NotExist']
519540
"""
520541
if names is None:
521542
return self.inputlist

0 commit comments

Comments
 (0)