Skip to content

Commit

Permalink
primitives: do not overwrite __eq__
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Nov 7, 2024
1 parent 092b474 commit 3bcf915
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pymbolic/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,9 +926,11 @@ def _augment_expression_dataclass(

from pytools.codegen import remove_common_indentation
augment_code = remove_common_indentation(
f"""
"""
from warnings import warn
from dataclasses import is_dataclass
"""
+ (f"""
def {cls.__name__}_eq(self, other):
Expand All @@ -951,6 +953,8 @@ def {cls.__name__}_eq(self, other):
return self.__class__ == other.__class__ and {comparison}
cls.__eq__ = {cls.__name__}_eq
""" if generate_hash else "")
+ (f"""
def {cls.__name__}_hash(self):
Expand All @@ -973,8 +977,9 @@ def {cls.__name__}_hash(self):
object.__setattr__(self, "_hash_value", hash_val)
return hash_val
if {generate_hash}:
cls.__hash__ = {cls.__name__}_hash
cls.__hash__ = {cls.__name__}_hash
""" if generate_hash else "")
+ f"""
def {cls.__name__}_init_arg_names(self):
Expand Down

0 comments on commit 3bcf915

Please sign in to comment.