Rule
import mathy_core.rule
BaseRule¶
BaseRule(self, args, kwargs)
apply_to¶
BaseRule.apply_to(
self,
node: mathy_core.expressions.MathExpression,
) -> 'ExpressionChangeRule'
can_apply_to¶
BaseRule.can_apply_to(self, node: mathy_core.expressions.MathExpression) -> bool
Performance Point
can_apply_to
is called very frequently during normal operation and should be implemented as efficiently as possible.
code¶
Short code for debug rendering. Should be two letters.
find_node¶
BaseRule.find_node(
self,
expression: mathy_core.expressions.MathExpression,
) -> Optional[mathy_core.expressions.MathExpression]
find_nodes¶
BaseRule.find_nodes(
self,
expression: mathy_core.expressions.MathExpression,
) -> List[mathy_core.expressions.MathExpression]
node.r_index
starting with index 0 name¶
Readable rule name used for debug rendering and description outputs
ExpressionChangeRule¶
ExpressionChangeRule(
self,
rule: mathy_core.rule.BaseRule,
node: Optional[mathy_core.expressions.MathExpression] = None,
)
done¶
ExpressionChangeRule.done(
self,
node: mathy_core.expressions.MathExpression,
) -> 'ExpressionChangeRule'
save_parent
was called. save_parent¶
ExpressionChangeRule.save_parent(
self,
parent: Optional[mathy_core.expressions.MathExpression] = None,
side: Optional[Literal['left', 'right']] = None,
) -> 'ExpressionChangeRule'