def filterResults(allResults, reportKeys, optimizeKey=None):
 optimizeDict = dict()
 allReportKeys = set()
 _appendReportKeys(keys=allReportKeys, prefix='', results=allResults)
 matchingKeys = _matchReportKeys(reportKeys, allReportKeys)
 reportDict = dict()
 for keyName in matchingKeys:
  value = _getReportItem(keyName, allResults)
  reportDict[keyName] = value
 if (optimizeKey is not None):
  matchingKeys = _matchReportKeys([optimizeKey], allReportKeys)
  if (len(matchingKeys) == 0):
   raise _BadKeyError(optimizeKey)
  elif (len(matchingKeys) > 1):
   raise _BadOptimizeKeyError(optimizeKey, matchingKeys)
  optimizeKeyFullName = matchingKeys[0]
  value = _getReportItem(optimizeKeyFullName, allResults)
  optimizeDict[optimizeKeyFullName] = value
  reportDict[optimizeKeyFullName] = value
 return (reportDict, optimizeDict)

def filterResults ( allResults , reportKeys , optimizeKey = None ) : optimizeDict = dict ( ) allReportKeys = set ( ) _appendReportKeys ( keys = allReportKeys , prefix = '' , results = allResults ) matchingKeys = _matchReportKeys ( reportKeys , allReportKeys ) reportDict = dict ( ) for keyName in matchingKeys : value = _getReportItem ( keyName , allResults ) reportDict [ keyName ] = value if ( optimizeKey is not None ) : matchingKeys = _matchReportKeys ( [ optimizeKey ] , allReportKeys ) if ( len ( matchingKeys ) == 0 ) : raise _BadKeyError ( optimizeKey ) elif ( len ( matchingKeys ) > 1 ) : raise _BadOptimizeKeyError ( optimizeKey , matchingKeys ) optimizeKeyFullName = matchingKeys [ 0 ] value = _getReportItem ( optimizeKeyFullName , allResults ) optimizeDict [ optimizeKeyFullName ] = value reportDict [ optimizeKeyFullName ] = value return ( reportDict , optimizeDict )
given the complete set of results generated by an experiment .