-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Population must be a sequence. For dicts or sets, use sorted(d) #732
Comments
It seems you are sorting a population represented by a dict or set, something like "pop.sorted()", which is not allowed. It usually works for list or ndarray. For sorting dict or set, you should use "sorted (pop)". |
Checked with a "print(type(pop))" and got "<class 'list'>"... as far as I can see, I don't believe I'm doing any sorting... Also, as I said, it works fine on another system - I'm going to test on yet another system... |
It would be easier to debug with minimal reproducing example posted in a gist or similar. |
Easy - take https://github.com/DEAP/deap/blob/master/examples/gp/parity.py and replace: toolbox.register("mate", gp.cxOnePoint) with toolbox.register("mate", gp.cxOnePointLeafBiased, termpb=0.1) On my one system it works, no problem, on the other I get:
|
Further investigation says it may be a change in Python 3.11 that is to blame. |
Added #733 pull request with the very minor change to fix. |
Thanks for debugging this! I'll check if any other place in the library needs to be changed and push to your branch. |
I'm getting this on one system running python 3.11.2, but the exact same code works fine on a system running python 3.10.12 - any thoughts?
The text was updated successfully, but these errors were encountered: