molfoundry.RCEvaluator#

class molfoundry.RCEvaluator(rules=(), *, intermediatePredicate=None, leftPredicate=None, rightPredicate=None, constraints=None)#

Bases: object

Evaluates rule-composition expressions.

Constructed with an optional rule database, exposed as ruleDatabase; the expressions carry their own concrete rules, so it is not otherwise needed. Evaluated rules are collected in createdRules.

intermediatePredicate / leftPredicate / rightPredicate and constraints apply to every composition the evaluator performs, unless an operator’s call form sets its own (see the module documentation).

Parameters:
eval(exp, *, onlyUnique=True)#

Evaluate exp into the list of composed rules.

With onlyUnique (default) duplicate results are removed by canonical form — the same deduplication RuleComposition.compose applies within a single composition, extended across every composed pair in the expression.

Pass onlyUnique=False to keep every composed rule, including isomorphic duplicates: one per surviving overlap within each composition and one per composed pair. This is what multiplicity experiments need — group the result by r.canonKey (e.g. with collections.Counter) to recover the multiplicity of each distinct composed rule.

Parameters:
Return type:

List[Rule]

iterate(exp, *, onlyUnique=True)#

Evaluate exp lazily into the rules eval() returns.

Yields the same rules as eval() for the same arguments, in the same order, and never None. The outermost compositions enumerate their candidate overlaps only as the loop asks for the next rule; overlaps rejected by the gluing, a predicate, or constraint transport, and duplicates under onlyUnique, are skipped, not yielded. Stopping early is therefore cheap, but one step may pass over many rejected overlaps, so the number of rules taken does not bound the work. Leaving the loop releases the enumeration, as does closing or dropping the generator.

The operands of the outermost compositions are evaluated eagerly first.

Parameters:
Return type:

Iterator[Rule]