Skip to content

Commit 6df54be

Browse files
committed
Improve getInputs docstring
1 parent 3202b0f commit 6df54be

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

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

0 commit comments

Comments
 (0)