mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-17 20:39:12 +00:00
Merge v1.0.0 (#682)
Co-authored-by: Kallinteris Andreas <30759571+Kallinteris-Andreas@users.noreply.github.com> Co-authored-by: Jet <38184875+jjshoots@users.noreply.github.com> Co-authored-by: Omar Younis <42100908+younik@users.noreply.github.com>
This commit is contained in:
27
tests/vector/utils/utils.py
Normal file
27
tests/vector/utils/utils.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""Utility functions for testing the vector utility functions."""
|
||||
import numpy as np
|
||||
|
||||
|
||||
def is_rng_equal(rng_1: np.random.Generator, rng_2: np.random.Generator):
|
||||
"""Asserts that two random number generates are equivalent."""
|
||||
return rng_1.bit_generator.state == rng_2.bit_generator.state
|
||||
|
||||
|
||||
def type_equivalence(data_1, data_2):
|
||||
"""Assert the type equivalences between two variables."""
|
||||
if type(data_1) == type(data_2):
|
||||
if isinstance(data_1, tuple):
|
||||
# assert len(data_1) == len(data_2), f'{len(data_1)}, {len(data_2)}, {data_1}, {data_2}'
|
||||
|
||||
for o_1, o_2 in zip(data_1, data_2):
|
||||
assert type_equivalence(
|
||||
o_1, o_2
|
||||
), f"{type(o_1)}, {type(o_2)}, {o_1}, {o_2}"
|
||||
elif isinstance(data_1, dict):
|
||||
for key in data_1:
|
||||
assert type_equivalence(
|
||||
data_1[key], data_2[key]
|
||||
), f"{type(data_1[key])}, {type(data_2[key])}, {key}, {data_1[key]}, {data_2[key]}"
|
||||
|
||||
return True
|
||||
assert False, f"{type(data_1)}, {type(data_2)}, {data_1}, {data_2}"
|
Reference in New Issue
Block a user