Skip to content

Commit

Permalink
add warnings for custom rules with symbolic parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
RazinShaikh committed Nov 14, 2023
1 parent 726ad18 commit 3cf6473
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions zxlive/custom_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,17 @@ def check_rule(rule: CustomRule, show_error: bool = True) -> bool:
else:
show_error_msg("Warning!", "The left-hand side and right-hand side of the rule have different semantics.")
return False
else:
if not (rule.rhs_graph.variable_types.items() <= rule.lhs_graph.variable_types.items()):
if show_error:
from .dialogs import show_error_msg
show_error_msg("Warning!", "The right-hand side has more free variables than the left-hand side.")
return False
for vertex in rule.lhs_graph.vertices():
if isinstance(rule.lhs_graph.phase(vertex), Poly):
if len(rule.lhs_graph.phase(vertex).free_vars()) > 1:
if show_error:
from .dialogs import show_error_msg
show_error_msg("Warning!", "Only one symbolic parameter per vertex is supported on the left-hand side.")
return False
return True

0 comments on commit 3cf6473

Please sign in to comment.