Package teamwork :: Package utils :: Module PsychUtils
[hide private]
[frames] | no frames]

Module PsychUtils

source code

Various utility methods for use by other PsychSim classes

Functions [hide private]
 
goalDiff(goalList1, goalList2)
Returns the difference in goal weights between two lists of goals of the form [(goal,weight),(goal,weight),...], where goal is either a PsychGoal object or a dictionary that is a suitable input to the PsychGoal constructor, and weight is a (possibly unnormalized) float
source code
 
generateMessages(factorList)
Takes a list of factors and generates all possible messages (i.e., all possible combinations of those factors
source code
 
noisyOR(probabilities)
Takes a list of probability values and computes a noisy OR
source code
 
act2dict(action, entities=[])
Translates an action in string form into a structured dictionary representation of that same action (e.g., 'CLF-violence-to-UrbanPoor' becomes {'actor':CLF,'type':'violence','object':UrbanPoor}
source code
 
dict2act(action)
Translates a structured dictionary representation of an action into a standardized string format (e.g., {'actor':CLF,'type':'violence','object':UrbanPoor} becomes 'CLF-violence-to-UrbanPoor'
source code
 
normalize(value)
Performs a floor and ceiling to keep the provided value within the range specified by the Interval class
source code
 
forceFloat(value)
Tries to convert the specified value into a float; if unable, returns 0.0 (avoids nasty exceptions)
source code
 
createObservation(act)
Translates an action (in either string or dictionary form) into a properly formatted observation dictionary for use by COM-MTDP code
source code
 
dict2str(dict, depth=-1) source code
 
debugger(level, str, debug)
Generic debugging statement that can handle three types of debug parameters: (1) Integer - prints string if debug >= level, (2) Tuple (debug,result) - appends string to result if debug >= level, and (3) List [debug,result,time] - if debug >= level, adds string to result along with time difference between now and provided time (side efffect: sets time to now)
source code
 
load(name)
Takes a file name (string) and reads a pickled Python object from the file and returns it
source code
 
extractEntity(name, entities) source code
 
extractAction(cmd, entities, format, debug=Debugger (0), actClass=None) source code
Variables [hide private]
  EMPTY_NAMESPACE = None
  EMPTY_PREFIX = None
  StringTypes = (<type 'str'>, <type 'unicode'>)
  XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'