Fix random seed int32 for Windows (#1655)

* reduce high in randint to avoid Windows oob error

* update changelog

* implements @MikhailGerasimov's suggestion

---------

Co-authored-by: Antonin RAFFIN <antonin.raffin@ensta.org>
This commit is contained in:
PatrickHelm 2023-08-30 10:56:58 +02:00 committed by GitHub
parent e9f0f23ce4
commit 5c93e9f426
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -3,7 +3,6 @@
Changelog
==========
Release 2.2.0a0 (WIP)
--------------------------
@ -21,6 +20,7 @@ New Features:
Bug Fixes:
^^^^^^^^^^
- Prevents OOB error on Windows if no seed is passed (@PatrickHelm)
Deprecations:
^^^^^^^^^^^^^
@ -1444,4 +1444,4 @@ And all the contributors:
@Melanol @qgallouedec @francescoluciano @jlp-ue @burakdmb @timothe-chaumont @honglu2875
@anand-bala @hughperkins @sidney-tio @AlexPasqua @dominicgkerr @Akhilez @Rocamonde @tobirohrer @ZikangXiong
@DavyMorgan @luizapozzobon @Bonifatius94 @theSquaredError @harveybellini @DavyMorgan @FieteO @jonasreiher @npit @WeberSamuel @troiganto
@lutogniew @lbergmann1 @lukashass @BertrandDecoster @pseudo-rnd-thoughts @stefanbschneider @kyle-he
@lutogniew @lbergmann1 @lukashass @BertrandDecoster @pseudo-rnd-thoughts @stefanbschneider @kyle-he @PatrickHelm

View file

@ -278,7 +278,7 @@ class VecEnv(ABC):
if seed is None:
# To ensure that subprocesses have different seeds,
# we still populate the seed variable when no argument is passed
seed = np.random.randint(0, 2**32 - 1)
seed = int(np.random.randint(0, np.iinfo(np.uint32).max, dtype=np.uint32))
self._seeds = [seed + idx for idx in range(self.num_envs)]
return self._seeds