Skip to content

Commit 214c657

Browse files
committed
Improve docstring for getContinuous()
1 parent 7a86ef4 commit 214c657

1 file changed

Lines changed: 34 additions & 7 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,40 @@ def getQuantities(self, names=None): # 3
557557

558558
raise ModelicaSystemError("Unhandled input for getQuantities()")
559559

560-
def getContinuous(self, names=None): # 4
561-
"""
562-
This method returns dict. The key is continuous names and value is corresponding continuous value.
563-
usage:
564-
>>> getContinuous()
565-
>>> getContinuous("Name1")
566-
>>> getContinuous(["Name1","Name2"])
560+
def getContinuous(self, names: Optional[str | list[str]] = None):
561+
"""Get values of continuous signals.
562+
563+
If called before simulate(), the initial values are returned as
564+
strings (or None). If called after simulate(), the final values (at
565+
stopTime) are returned as numpy.float64.
566+
567+
Args:
568+
names: Either None (default), a string with the continuous signal
569+
name, or a list of signal name strings.
570+
Returns:
571+
If `names` is None, a dict in the format
572+
{signal_name: signal_value} is returned.
573+
If `names` is a string, a single element list [signal_value] is
574+
returned.
575+
If `names` is a list, a list with one value for each signal name
576+
in names is returned: [signal1_value, signal2_value, ...].
577+
578+
Examples:
579+
Before simulate():
580+
>>> mod.getContinuous()
581+
{'x': '1.0', 'der(x)': None, 'y': '-0.4'}
582+
>>> mod.getContinuous("y")
583+
['-0.4']
584+
>>> mod.getContinuous(["y","x"])
585+
['-0.4', '1.0']
586+
587+
After simulate():
588+
>>> mod.getContinuous()
589+
{'x': np.float64(0.68), 'der(x)': np.float64(-0.24), 'y': np.float64(-0.24)}
590+
>>> mod.getContinuous("x")
591+
[np.float64(0.68)]
592+
>>> mod.getOutputs(["y","x"])
593+
[np.float64(-0.24), np.float64(0.68)]
567594
"""
568595
if not self._simulationFlag:
569596
if names is None:

0 commit comments

Comments
 (0)