dm_env icon indicating copy to clipboard operation
dm_env copied to clipboard

Fix generate_value() in BoundedArray to correctly sample within bounds

Open Pranav-0440 opened this issue 1 month ago • 0 comments

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).

Pranav-0440 avatar Nov 22 '25 18:11 Pranav-0440