qnet.utils.check_rules module¶
Utilities for algebraic rules
Summary¶
Functions:
check_rules_dict |
Verify the rules that classes may use for the _rules or _binary_rules class attribute. |
Reference¶
-
qnet.utils.check_rules.check_rules_dict(rules)[source]¶ Verify the rules that classes may use for the _rules or _binary_rules class attribute.
Specifically, rules must be a
OrderedDict-compatible object (list of key-value tuples,dict,OrderedDict) that maps a rule name (str) to a rule. Each rule consists of aPatternand a replaceent callable. The Pattern must be set up to match aProtoExpr. That is, the Pattern should be constructed through thepattern_head()routine.Raises: TypeError– If rules is not compatible withOrderedDict, the keys in rules are not strings, or rule is not a tuple of (Pattern, callable)ValueError– If the head-attribute of each Pattern is not an instance ofProtoExpr, or if there are duplicate keys in rules
Returns: OrderedDictof rules