SimonBlanke / Gradient-Free-Optimizers

Simple and reliable optimization with local, global, population-based and sequential techniques in numerical discrete search spaces.
https://simonblanke.github.io/gradient-free-optimizers-documentation
MIT License
1.21k stars 84 forks source link

ImportError: cannot import name 'gcd' from 'fractions' #23

Closed d416 closed 2 years ago

d416 commented 2 years ago

Describe the bug

In Python 3.9, using gradient_free_optimizers returns ImportError: cannot import name 'gcd' from 'fractions'

Code to reproduce the behavior

https://github.com/SimonBlanke/Gradient-Free-Optimizers/blob/master/examples/convex_function.py

Error message from command line ImportError: cannot import name 'gcd' from 'fractions'

System information:

Additional context

It looks like fractions.gcd was deprecated in Python 3.9 and replaced with math.gcd https://stackoverflow.com/questions/66174862/import-error-cant-import-name-gcd-from-fractions/67540570#67540570

SimonBlanke commented 2 years ago

Hello @d416,

Thank you for opening this issue. Very interesting find! :-)

From the link you posted I can see that math.gcd is the way to go for >= python 3.5.

SimonBlanke commented 2 years ago

Hello @d416,

I fixed this error in e2e6537e7f9d3d33db8511d400fb284e345d7c13 and added python 3.9 to the testing in a27ec7775a961877dfb7aed7511383e4e4aa01b1. I just released the fix in v1.0.6.

Thank you for contributing to GFO :-)