Package teamwork :: Package math :: Module rules
[hide private]
[frames] | no frames]

Module rules

source code

Code for manipulating a rule-based representation of PWL functions

Classes [hide private]
  Rule
Representation of a single rule.
Functions [hide private]
 
applyRules(state, rules, attributes, values, target, checkForDuplicates=False) source code
 
mergeAttributes(original, rules, new) source code
 
internalCheck(rules, attributes, values, target, debug=False)
Test whether any redundant/inconsistent attribute assignments are present
source code
 
clusterRules(rules, values) source code
 
pruneRules(original, attributes, values, debug=False) source code
 
addRules(set1, set2, attributes, values) source code
 
multiplyRules(set1, set2, attributes, values, interrupt=None) source code
 
mapValues(rules, values, op)
Applies a fixed transformation to the RHS of a set of rules
source code
dict[]
replaceValues(rules, attributes, oldValues, mapping, newValues)
Use RHS values to trigger a second set of rules, and return a merged set of the two
source code
Variables [hide private]
  __PROFILE__ = False
Function Details [hide private]

mapValues(rules, values, op)

source code 

Applies a fixed transformation to the RHS of a set of rules

Parameters:
  • rules (dict[]) - the set of rules to transform (left unchanged)
  • values (dict) - the dictionary of current RHS values
  • op - the transformation, a function that takes a single RHS value as input and returns the new RHS value (assumed to be a 1-1 mapping)

replaceValues(rules, attributes, oldValues, mapping, newValues)

source code 

Use RHS values to trigger a second set of rules, and return a merged set of the two

Parameters:
  • rules (dict[]) - the original rule set
  • attributes (dict) - the attribute set for both sets of rules
  • oldValues (dict) - the set of values for only the original set of rules
  • mapping (dict:str→dict[]) - a dictionary of rule sets, indexed by value labels from the original set of rules
  • newValues (dict) - the set of values for only the new set of rules
Returns: dict[]
the new rules merging the two sets