Skip to content

Commit

Permalink
Change seeding error message to report seed type (#74)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Towers <[email protected]>
  • Loading branch information
theo-brown and pseudo-rnd-thoughts authored Nov 11, 2022
1 parent 1956e64 commit ae3a04e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gymnasium/utils/seeding.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ def np_random(seed: Optional[int] = None) -> Tuple[np.random.Generator, Any]:
Error: Seed must be a non-negative integer or omitted
"""
if seed is not None and not (isinstance(seed, int) and 0 <= seed):
raise error.Error(f"Seed must be a non-negative integer or omitted, not {seed}")
if isinstance(seed, int) is False:
raise error.Error(
f"Seed must be a python integer, actual type: {type(seed)}"
)
else:
raise error.Error(
f"Seed must be greater or equal to zero, actual value: {seed}"
)

seed_seq = np.random.SeedSequence(seed)
np_seed = seed_seq.entropy
Expand Down

0 comments on commit ae3a04e

Please sign in to comment.