From a3d0f9ff5755ef264c3a879d7c28bf027a316b05 Mon Sep 17 00:00:00 2001 From: trevorstephens Date: Sat, 27 Aug 2016 13:08:01 -0700 Subject: [PATCH] simplify function set creation --- gplearn/functions.py | 28 ++++++++++++++-------------- gplearn/genetic.py | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gplearn/functions.py b/gplearn/functions.py index d94f56ee..5fdc6ea9 100644 --- a/gplearn/functions.py +++ b/gplearn/functions.py @@ -146,17 +146,17 @@ def _protected_inverse(x1): cos1 = make_function(function=np.cos, name='cos', arity=1) tan1 = make_function(function=np.tan, name='tan', arity=1) -_function_map = {'add': [add2], - 'sub': [sub2], - 'mul': [mul2], - 'div': [div2], - 'sqrt': [sqrt1], - 'log': [log1], - 'abs': [abs1], - 'neg': [neg1], - 'inv': [inv1], - 'max': [max2], - 'min': [min2], - 'sin': [sin1], - 'cos': [cos1], - 'tan': [tan1]} +_function_map = {'add': add2, + 'sub': sub2, + 'mul': mul2, + 'div': div2, + 'sqrt': sqrt1, + 'log': log1, + 'abs': abs1, + 'neg': neg1, + 'inv': inv1, + 'max': max2, + 'min': min2, + 'sin': sin1, + 'cos': cos1, + 'tan': tan1} diff --git a/gplearn/genetic.py b/gplearn/genetic.py index fb27ee01..bf7cd180 100644 --- a/gplearn/genetic.py +++ b/gplearn/genetic.py @@ -932,7 +932,7 @@ def fit(self, X, y, sample_weight=None): if function not in _function_map: raise ValueError('invalid function name %s found in ' '`function_set`.' % function) - self._function_set.extend(_function_map[function]) + self._function_set.append(_function_map[function]) elif isinstance(function, _Function): self._function_set.append(function) else: