In the following Enum inheritance calling a polymorphic method on the members' value gives an unexpected result.
from enum import Enum
class Activation:
def activate(self, value):
print("in activation")
pass
def derivative(self, value):
pass
class Relu(Activation):
def activate(self, value):
print('in relu')
return max(0, value)
def derivative(self, value):
return 0 if value<= 0 else 1
class Activations(Activation, Enum):
RELU = Relu()
#TANH = Tanh()
#SIGMOID = Sigmoid()
#SOFTMAX = Softmax()
activ1 = Relu().activate(11) # output: in relu
activ2 = Activations.RELU.activate(11) # output: in activation
activ2 output is 'in activation', while desired output is 'in relu'.