@@ -545,14 +545,42 @@ def getInputs(self, names: Optional[str | list[str]] = None) -> dict | list: #
545545 elif isinstance (names , list ):
546546 return ([self .inputlist .get (x , "NotExist" ) for x in names ])
547547
548- def getOutputs (self , names = None ): # 7
549- """
550- This method returns dict. The key is output names and value is corresponding output value.
551- If name is None then the function will return dict which contain all output names as key and value as corresponding values. eg., getOutputs()
552- usage:
553- >>> getOutputs()
554- >>> getOutputs("Name1")
555- >>> getOutputs(["Name1","Name2"])
548+ def getOutputs (self , names : Optional [str | list [str ]] = None ): # 7
549+ """Get output values.
550+
551+ If called before simulate(), the initial values are returned as
552+ strings. If called after simulate(), the final values (at stopTime)
553+ are returned as numpy.float64.
554+
555+ Args:
556+ names: Either None (default), a string with the output name,
557+ or a list of output name strings.
558+ Returns:
559+ If `names` is None, a dict in the format
560+ {output_name: output_value} is returned.
561+ If `names` is a string, a single element list [output_value] is
562+ returned.
563+ If `names` is a list, a list with one value for each output name
564+ in names is returned: [output1_value, output2_value, ...].
565+
566+ Examples:
567+ Before simulate():
568+ >>> mod.getOutputs()
569+ {'out1': '-0.4', 'out2': '1.2'}
570+ >>> mod.getOutputs("out1")
571+ ['-0.4']
572+ >>> mod.getOutputs(["out1","out2"])
573+ ['-0.4', '1.2']
574+ >>> mod.getOutputs("ThisOutputDoesNotExist")
575+ ['NotExist']
576+
577+ After simulate():
578+ >>> mod.getOutputs()
579+ {'out1': np.float64(-0.1234), 'out2': np.float64(2.1)}
580+ >>> mod.getOutputs("out1")
581+ [np.float64(-0.1234)]
582+ >>> mod.getOutputs(["out1","out2"])
583+ [np.float64(-0.1234), np.float64(2.1)]
556584 """
557585 if not self .simulationFlag :
558586 if names is None :
0 commit comments