dm_env
dm_env copied to clipboard
Fix generate_value() in BoundedArray to correctly sample within bounds
Title
Fix generate_value() in BoundedArray to correctly sample within bounds
Description
This PR addresses Issue #12 ("generate_value"), where BoundedArray.generate_value() produced arrays filled with the minimum value instead of generating random values within the [minimum, maximum] range.
Changes
- Updated generate_value() to sample using np.random.uniform(low, high, size) and cast to dtype.
- Ensures values respect the spec’s shape, dtype, and bounds.
- Added unit test test_generate_value_within_bounds() verifying correct behavior.
Why
The previous implementation ignored maximum and did not create meaningful test values. This update aligns BoundedArray.generate_value() with expected semantics for bounded specs.
All tests passed (165 passed in 4.37s).