geatpy-dev / geatpy

Evolutionary algorithm toolbox and framework with high performance for Python
http://www.geatpy.com
GNU Lesser General Public License v3.0
2.02k stars 726 forks source link

SEGA回调函数self.outFunc有问题,之前NSGA中并没有存在该问题 #348

Closed RebelYoung closed 11 months ago

RebelYoung commented 11 months ago

image

我写了个回调函数call_back2type(call_back2)输出是function,而type(call_back2)本身的type又不是str而是type,那么type(outFunc)是肯定!='function'字符串的。应该改成

t=type(func) # 写个函数func
isinstance(outFunc,t) # 结果是Ture
str(type(call_back2))=="<class 'function'>" # 结果也是True 

# 但是源码中用的是
type(self.outFunc) == 'function' # 结果是False
RebelYoung commented 11 months ago

@geatpy-dev

geatpy-dev commented 11 months ago

应该用if not callable(self.outFunc),之前改过的。代码貌似被后面的人该回去了。你修改一下即可。

geatpy-dev commented 11 months ago

修改方法见:https://github.com/geatpy-dev/geatpy/issues/292