ReplacementRule
- class ReplacementRule(application_type: RuleApplicationType | Evaluatable[RuleApplicationType], query: ShapeQuery, rhs: Shape)
A
ReplacementRule
computes thex -> y
rule schema.Specifically, given a
lhs
u
,rhs
v
, and designw
, it computes the transformationsf_i
that embedu
inw
. Then it replacesw
withw - f_i(u) + f_i(v)
appropriate to theapplication_type
. The selection mode chooses thef_i
to apply. If the selection mode isALL
,w
is replaced byw - Σf_i(u) + Σf_i(v)
. The transformations are computed with thequery_transformation
’scompute()
method.- Parameters:
application_type – The
RuleApplicationType
to use when selecting a match to apply the rule to.query – The
ShapeQuery
to use when searching (u
).rhs – The
Shape
to replace thelhs
with in a design (v
).
Attributes
The
Shape
to replace thelhs
with in a design.The
RuleApplicationType
to use when selecting a match to apply the rule to.Methods
- apply_to(shape: Shape, communication_layer: CommunicationLayer, in_automation: bool = False, _to_design: ndarray = array([0., 0., 0.])) Tuple[Rule, List[Tuple[Shape, Shape]], Shape, Shape, Shape, Shape]
-
- Parameters:
shape – The shape to apply this rule to.
communication_layer – The
CommunicationLayer
to use during rule application.in_automation – Whether this rule is being applied as part of an automation (e.g.: as part of a
RuleSequence
orProgram
)._to_design – Vector used to relocate the matches to the design in application previews and enumerations. This is needed because the
ShapeMachine
engine internally shifts itsinitial_design
to the origin to reduce floating-point error.
- Returns:
The shape created as a result of rule application.
- application_type
The
RuleApplicationType
to use when selecting a match to apply the rule to.