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