Change seeding error message to report seed type (#74)

Co-authored-by: Mark Towers <mark.m.towers@gmail.com>
This commit is contained in:
Theo Brown
2022-11-11 14:22:59 +00:00
committed by GitHub
parent 1956e648f9
commit ae3a04ec6b

View File

@@ -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