Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions deap/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,25 @@ class Terminal(object):
def __init__(self, terminal, symbolic, ret):
self.ret = ret
self.value = terminal
self.name = str(terminal)
#self.name = str(terminal)
if callable(self.value):
self.name = self.value.__name__
else:
self.name = str(terminal)
self.conv_fct = str if symbolic else repr

@property
def arity(self):
return 0

def format(self):
return self.conv_fct(self.value)
if callable(self.value):
return (self.name + "()")
else:
return self.conv_fct(self.value)

#def format(self):
# return self.conv_fct(self.value)

def __eq__(self, other):
if type(self) is type(other):
Expand Down Expand Up @@ -368,7 +378,7 @@ def addTerminal(self, terminal, ret_type, name=None):

if name is not None:
self.context[name] = terminal
terminal = name
#terminal = name
symbolic = True
elif terminal in (True, False):
# To support True and False terminals with Python 2.
Expand Down