diff --git a/pymbolic/primitives.py b/pymbolic/primitives.py index d267f83bcc8687d13a5f11be6acb6f80bd50d824..5ad5eb017fc9dc05e3c387297310fdabb7fc84c4 100644 --- a/pymbolic/primitives.py +++ b/pymbolic/primitives.py @@ -21,6 +21,7 @@ THE SOFTWARE. """ from sys import intern +from abc import ABC, abstractmethod import pymbolic.traits as traits @@ -180,7 +181,7 @@ def disable_subscript_by_getitem(): pass -class Expression: +class Expression(ABC): """Superclass for parts of a mathematical expression. Overrides operators to implicitly construct :class:`Sum`, :class:`Product` and other expressions. @@ -226,6 +227,10 @@ class Expression: # {{{ init arg names (override by subclass) + @abstractmethod + def __getinitargs__(self): + pass + @property def init_arg_names(self): raise NotImplementedError @@ -539,9 +544,6 @@ class Expression: self._hash_value = self.get_hash() return self._hash_value - def __getinitargs__(self): - raise NotImplementedError - def __getstate__(self): return self.__getinitargs__()