Skip to content

Commit

Permalink
shuffle methods inside ExpressionPattern
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Sep 17, 2024
1 parent 4b7befb commit f7c0785
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions mathics/core/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,19 @@ class ExpressionPattern(Pattern):
# get_pre_choices = pattern_nocython.get_pre_choices
# match = pattern_nocython.match

def __init__(self, expr: Expression, evaluation: Optional[Evaluation] = None):
self.expr = expr
head = expr.head
attributes = (
None if evaluation is None else head.get_attributes(evaluation.definition)
)
self.__set_pattern_attributes__(attributes)
self.head = Pattern.create(head)
self.elements = [Pattern.create(element) for element in expr.elements]

def __set_pattern_attributes__(self, attributes):
self.attributes = attributes

def match(
self,
yield_func: Callable,
Expand Down Expand Up @@ -461,19 +474,6 @@ def get_pre_choices(
else:
yield_choice(vars_dict)

def __init__(self, expr: Expression, evaluation: Optional[Evaluation] = None):
self.expr = expr
head = expr.head
attributes = (
None if evaluation is None else head.get_attributes(evaluation.definition)
)
self.__set_pattern_attributes__(attributes)
self.head = Pattern.create(head)
self.elements = [Pattern.create(element) for element in expr.elements]

def __set_pattern_attributes__(self, attributes):
self.attributes = attributes

def filter_elements(self, head_name: str):
"""Filter the elements with a given head_name"""
head_name = ensure_context(head_name)
Expand Down

0 comments on commit f7c0785

Please sign in to comment.