Skip to content
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

env.seed(...) sometimes does not work and throw an error #331

Closed
BDonnot opened this issue Jun 9, 2022 · 1 comment · Fixed by #355
Closed

env.seed(...) sometimes does not work and throw an error #331

BDonnot opened this issue Jun 9, 2022 · 1 comment · Fixed by #355
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@BDonnot
Copy link
Collaborator

BDonnot commented Jun 9, 2022

Environment

  • Grid2op version: 1.7.1
  • System: ubuntu
  • Additional system information NA

Bug description

env.seed(2735729614) will raise an error.

How to reproduce

Command line

# command line used if any 

Code snippet

import grid2op
env = grid2op.make("l2rpn_case14_sandbox", test=True)
env.seed(2735729614)

Current output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./Environment/BaseEnv.py", line 1210, in seed
    super().seed(seed_init)
  File "./Space/RandomObject.py", line 133, in seed
    self.space_prng.seed(seed=self.seed_used)
  File "mtrand.pyx", line 245, in numpy.random.mtrand.RandomState.seed
  File "_mt19937.pyx", line 166, in numpy.random._mt19937.MT19937._legacy_seeding
  File "_mt19937.pyx", line 180, in numpy.random._mt19937.MT19937._legacy_seeding
ValueError: Seed must be between 0 and 2**32 - 1

Expected output

Nothing

@BDonnot BDonnot added bug Something isn't working good first issue Good for newcomers labels Jun 9, 2022
@BDonnot
Copy link
Collaborator Author

BDonnot commented Jun 9, 2022

This is because the seed here is too large for grid2op. It would be ok for numpy random but grid2op cast it to int32 which causes this number to be negative and unsuitable for seeding.

I fixed it by raising an error in this case.

BDonnot referenced this issue in BDonnot/Grid2Op Jun 9, 2022
@BDonnot BDonnot linked a pull request Jul 5, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant