molfoundry.RCEvaluator#
- class molfoundry.RCEvaluator(rules=(), *, intermediatePredicate=None, leftPredicate=None, rightPredicate=None, constraints=None)#
Bases:
objectEvaluates 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 increatedRules.intermediatePredicate/leftPredicate/rightPredicateandconstraintsapply to every composition the evaluator performs, unless an operator’s call form sets its own (see the module documentation).- Parameters:
intermediatePredicate (Callable[[CompositionGraph], bool] | None)
leftPredicate (Callable[[CompositionGraph], bool] | None)
rightPredicate (Callable[[CompositionGraph], bool] | None)
constraints (Iterable[IncidenceConstraint] | None)
- eval(exp, *, onlyUnique=True)#
Evaluate
expinto the list of composed rules.With
onlyUnique(default) duplicate results are removed by canonical form — the same deduplicationRuleComposition.composeapplies within a single composition, extended across every composed pair in the expression.Pass
onlyUnique=Falseto 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 byr.canonKey(e.g. withcollections.Counter) to recover the multiplicity of each distinct composed rule.
- iterate(exp, *, onlyUnique=True)#
Evaluate
explazily into the ruleseval()returns.Yields the same rules as
eval()for the same arguments, in the same order, and neverNone. 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 underonlyUnique, 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.