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

Fix python 3.11 random seeding #34

Closed 23pointsNorth closed 2 years ago

23pointsNorth commented 2 years ago

The issue originated from https://github.com/SimonBlanke/Hyperactive/pull/58 can be summarized around seeding pyhton seeds with non pytonic values. At it's core it is as follows:

>>> import numpy as np
>>> a = np.random.randint(0, high=2 ** 31 - 2, dtype=np.int64)
>>> type(a)
<class 'numpy.int64'>
>>> type(a.item())
<class 'int'>

>>> a
518627337
>>> a.item()
518627337 # confirms the value doesn't change

Thus, with the new requirements for python 3.11 to accept python types, we can convert the numpy int to a pythonic int.

The python 3.11 job succeeds - https://github.com/23pointsNorth/Gradient-Free-Optimizers/actions/runs/3427292210/jobs/5710490773 though some issues with 3.5/6 are flagged, but I am unsure if they are related to this change or how python versions are selected from here

Hope this help (the rabbit hole at https://github.com/holoviz/param/issues/602 was interesting, but hopefully the fix here would be much simpler).

codecov[bot] commented 2 years ago

Codecov Report

Base: 95.25% // Head: 95.25% // No change to project coverage :thumbsup:

Coverage data is based on head (94cc254) compared to base (a8b799c). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #34 +/- ## ======================================= Coverage 95.25% 95.25% ======================================= Files 53 53 Lines 2108 2108 ======================================= Hits 2008 2008 Misses 100 100 ``` | [Impacted Files](https://codecov.io/gh/SimonBlanke/Gradient-Free-Optimizers/pull/34?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Blanke) | Coverage Δ | | |---|---|---| | [gradient\_free\_optimizers/utils.py](https://codecov.io/gh/SimonBlanke/Gradient-Free-Optimizers/pull/34/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Blanke#diff-Z3JhZGllbnRfZnJlZV9vcHRpbWl6ZXJzL3V0aWxzLnB5) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Blanke). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Blanke)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

SimonBlanke commented 2 years ago

Hello @23pointsNorth,

thanks for the quick fix!

I am not sure why the 3.5 and 3.6 test run failed, but I will look into this. My local tests and remote tests look good. I just released v1.2.3 with the included fix for python 3.11, so that we can use it for the Hyperactive tests later.