From d28f86c82b13947987d273ee9f0c7af7d6999c6d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 20 Feb 2014 13:22:51 -0600 Subject: [PATCH] Force ReductionOperation subclasses to pay attention to hash and comparison requirement --- loopy/library/reduction.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/loopy/library/reduction.py b/loopy/library/reduction.py index 865ed1d66..650d1e452 100644 --- a/loopy/library/reduction.py +++ b/loopy/library/reduction.py @@ -40,6 +40,14 @@ class ReductionOperation(object): def neutral_element(self, dtype, inames): raise NotImplementedError + def __hash__(self): + # Force subclasses to override + raise NotImplementedError + + def __eq__(self, other): + # Force subclasses to override + raise NotImplementedError + def __call__(self, dtype, operand1, operand2, inames): raise NotImplementedError @@ -142,6 +150,12 @@ class _ArgExtremumReductionOperation(ReductionOperation): def neutral_element(self, dtype, inames): return ArgExtFunction(self, dtype, "init", inames)() + def __hash__(self): + return hash(type(self)) + + def __eq__(self, other): + return type(self) == type(other) + def __call__(self, dtype, operand1, operand2, inames): iname, = inames -- GitLab