@@ -492,14 +492,42 @@ def getInputs(self, names: Optional[str | list[str]] = None) -> dict | list: #
492492 elif isinstance (names , list ):
493493 return ([self .inputlist .get (x , "NotExist" ) for x in names ])
494494
495- def getOutputs (self , names = None ): # 7
496- """
497- This method returns dict. The key is output names and value is corresponding output value.
498- If name is None then the function will return dict which contain all output names as key and value as corresponding values. eg., getOutputs()
499- usage:
500- >>> getOutputs()
501- >>> getOutputs("Name1")
502- >>> getOutputs(["Name1","Name2"])
495+ def getOutputs (self , names : Optional [str | list [str ]] = None ): # 7
496+ """Get output values.
497+
498+ If called before simulate(), the initial values are returned as
499+ strings. If called after simulate(), the final values (at stopTime)
500+ are returned as numpy.float64.
501+
502+ Args:
503+ names: Either None (default), a string with the output name,
504+ or a list of output name strings.
505+ Returns:
506+ If `names` is None, a dict in the format
507+ {output_name: output_value} is returned.
508+ If `names` is a string, a single element list [output_value] is
509+ returned.
510+ If `names` is a list, a list with one value for each output name
511+ in names is returned: [output1_value, output2_value, ...].
512+
513+ Examples:
514+ Before simulate():
515+ >>> mod.getOutputs()
516+ {'out1': '-0.4', 'out2': '1.2'}
517+ >>> mod.getOutputs("out1")
518+ ['-0.4']
519+ >>> mod.getOutputs(["out1","out2"])
520+ ['-0.4', '1.2']
521+ >>> mod.getOutputs("ThisOutputDoesNotExist")
522+ ['NotExist']
523+
524+ After simulate():
525+ >>> mod.getOutputs()
526+ {'out1': np.float64(-0.1234), 'out2': np.float64(2.1)}
527+ >>> mod.getOutputs("out1")
528+ [np.float64(-0.1234)]
529+ >>> mod.getOutputs(["out1","out2"])
530+ [np.float64(-0.1234), np.float64(2.1)]
503531 """
504532 if not self .simulationFlag :
505533 if names is None :
0 commit comments