I got a problem using the module and the stats module. Maybe one of the experienced users may help me with that.
Before: I'm using the module since more than 2 years, this is the first time this error occurs (therefore I think it comes from my side).
I'm creating an EA using DEAP 1.1. Individuals consist of Integer lists, where each element may be 0 or 1. The population itself is again a list.
stats = tools.Statistics(key=lambda ind: ind.fitness.values)
time_start = time.time()
def timecap(ind):
return time.time() - time_start
stats.register("avg", np.mean)
stats.register("med", np.median)
stats.register("std", np.std)
stats.register("min", np.min)
stats.register("max", np.max)
stats.register("time", timecap)
Occasionally (sometimes after 1,000,000 evaluations / 200 generations, sometimes right after the start with the initial population), the following error occurs:
File "/home/robin/workspace/untitled/monitor_selection.py", line 219, in EA
record = stats.compile(population) if stats is not None else {}
File "/usr/local/lib/python3.5/dist-packages/deap-1.1.0-py3.5-linux-x86_64.egg/deap/tools/support.py", line 208, in compile
entry[key] = func(values)
File "/usr/local/lib/python3.5/dist-packages/numpy/core/fromnumeric.py", line 2992, in std
keepdims=keepdims)
File "/usr/local/lib/python3.5/dist-packages/numpy/core/_methods.py", line 124, in _std
keepdims=keepdims)
File "/usr/local/lib/python3.5/dist-packages/numpy/core/_methods.py", line 94, in _var
arrmean, rcount, out=arrmean, casting='unsafe', subok=False)
TypeError: unsupported operand type(s) for /: 'tuple' and 'int'
I tried to debug the code using PyCharms debugger, but unfortunately I can't find an error in my code (especially when it runs in most cases).
Do you have any idea?
Thank you very much in advance!