Skip to content

Commit 9478633

Browse files
committed
Improve getInputs docstring
1 parent b746a39 commit 9478633

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
@@ -458,11 +458,32 @@ def getParameters(self, names: Optional[str | list[str]] = None) -> dict[str, st
458458
elif isinstance(names, list):
459459
return ([self.paramlist.get(x, "NotExist") for x in names])
460460

461-
def getInputs(self, names=None): # 6
462-
"""
463-
This method returns dict. The key is input names and value is corresponding input value.
464-
If *name is None then the function will return dict which contain all input names as key and value as corresponding values. eg., getInputs()
465-
Otherwise variable number of arguments can be passed as input name in string format separated by commas. eg., getInputs('iName1', 'iName2')
461+
def getInputs(self, names: Optional[str | list[str]] = None) -> dict | list: # 6
462+
"""Get input values.
463+
464+
Args:
465+
names: Either None (default), a string with the input name,
466+
or a list of input name strings.
467+
Returns:
468+
If `names` is None, a dict in the format
469+
{input_name: input_value} is returned.
470+
If `names` is a string, a single element list [input_value] is
471+
returned.
472+
If `names` is a list, a list with one value for each input name
473+
in names is returned: [input1_values, input2_values, ...].
474+
In all cases, input values are returned as a list of tuples,
475+
where the first element in the tuple is the time and the second
476+
element is the input value.
477+
478+
Examples:
479+
>>> mod.getInputs()
480+
{'Name1': [(0.0, 0.0), (1.0, 1.0)], 'Name2': None}
481+
>>> mod.getInputs("Name1")
482+
[[(0.0, 0.0), (1.0, 1.0)]]
483+
>>> mod.getInputs(["Name1","Name2"])
484+
[[(0.0, 0.0), (1.0, 1.0)], None]
485+
>>> mod.getInputs("ThisInputDoesNotExist")
486+
['NotExist']
466487
"""
467488
if names is None:
468489
return self.inputlist

0 commit comments

Comments
 (0)