Skip to content

Commit 72f8033

Browse files
committed
Improve docstring for getContinuous()
1 parent 2621bb8 commit 72f8033

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
@@ -595,13 +595,40 @@ def getQuantities(self, names: Optional[str | list[str]] = None) -> list[dict]:
595595

596596
raise ModelicaSystemError("Unhandled input for getQuantities()")
597597

598-
def getContinuous(self, names=None): # 4
599-
"""
600-
This method returns dict. The key is continuous names and value is corresponding continuous value.
601-
usage:
602-
>>> getContinuous()
603-
>>> getContinuous("Name1")
604-
>>> getContinuous(["Name1","Name2"])
598+
def getContinuous(self, names: Optional[str | list[str]] = None):
599+
"""Get values of continuous signals.
600+
601+
If called before simulate(), the initial values are returned as
602+
strings (or None). If called after simulate(), the final values (at
603+
stopTime) are returned as numpy.float64.
604+
605+
Args:
606+
names: Either None (default), a string with the continuous signal
607+
name, or a list of signal name strings.
608+
Returns:
609+
If `names` is None, a dict in the format
610+
{signal_name: signal_value} is returned.
611+
If `names` is a string, a single element list [signal_value] is
612+
returned.
613+
If `names` is a list, a list with one value for each signal name
614+
in names is returned: [signal1_value, signal2_value, ...].
615+
616+
Examples:
617+
Before simulate():
618+
>>> mod.getContinuous()
619+
{'x': '1.0', 'der(x)': None, 'y': '-0.4'}
620+
>>> mod.getContinuous("y")
621+
['-0.4']
622+
>>> mod.getContinuous(["y","x"])
623+
['-0.4', '1.0']
624+
625+
After simulate():
626+
>>> mod.getContinuous()
627+
{'x': np.float64(0.68), 'der(x)': np.float64(-0.24), 'y': np.float64(-0.24)}
628+
>>> mod.getContinuous("x")
629+
[np.float64(0.68)]
630+
>>> mod.getOutputs(["y","x"])
631+
[np.float64(-0.24), np.float64(0.68)]
605632
"""
606633
if not self._simulationFlag:
607634
if names is None:

0 commit comments

Comments
 (0)