Skip to content

Commit

Permalink
rename test
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigodelazcano committed Nov 29, 2023
1 parent 0c67c3b commit 98af413
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/content/dataset_standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ As mentioned in the `Supported Spaces` section, many different observation and a



When creating a dataset with `DataCollectorV0`, if the `DataCollectorV0` is initialized with `record_infos=True`, the additional information stored as step infos must be provided to Minari as a dict, which can only contain strings as keys and other dictionaries or `np.ndarray` as values. An info dict must be provided from every call to the wrapped evironment's `step` and `reset` function, and the shape of each `np.ndarray` must stay the same across timesteps, and the keys must remain the same in all `dicts` across timesteps.
When creating a dataset with `DataCollectorV0`, if the `DataCollectorV0` is initialized with `record_infos=True`, the additional information stored as step infos must be provided to Minari as a dict, which can only contain strings as keys and other dictionaries or `np.ndarray` as values. An info dict must be provided from every call to the wrapped evironment's `step` and `reset` function, and the shape of each `np.ndarray` must stay the same across timesteps, and the keys must remain the same in all `dicts` across timesteps.

Here is an example of what a valid `info` might look like:

Expand All @@ -571,8 +571,8 @@ Here is an example of what a valid `info` might look like:
info = {'value_1':np.array([1]), 'value_2': {"sub_value_1":np.asarray([[2.3],[4.5]])}}
```

Note that this shows how `infos` can be structured hierarchically, and that the nesting of dicts can go to arbitrary depth.
Note that this shows how `infos` can be structured hierarchically, and that the nesting of dicts can go to arbitrary depth.

Given that it is not guaranteed that all Gymnasium environments provide infos at every timestep, we provide the `StepDataCallback` which can modify the infos from a non-compliant environment so they have the same structure at every timestep. An example of this pattern is available in our test `test_data_collector_step_data_callback_info_correction` in test_step_data_callback.py.

We provide tests to guarantee support for the following `numpy.ndarray` data types: `np.int8`,`np.int16`,`np.int32`,`np.int64`, `np.uint8`,`np.uint16`,`np.uint32`,`np.iunt64`,`np.float16`,`np.float32`,`np.float64`.
We provide tests to guarantee support for the following `numpy.ndarray` data types: `np.int8`,`np.int16`,`np.int32`,`np.int64`, `np.uint8`,`np.uint16`,`np.uint32`,`np.iunt64`,`np.float16`,`np.float32`,`np.float64`.
8 changes: 2 additions & 6 deletions tests/utils/test_dataset_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def test_generate_dataset_with_collector_env(dataset_id, env_id):
("dummy-tuple-test-v0", "DummyTupleEnv-v0", None),
],
)
def test_generate_dataset_with_collector_env_infos(dataset_id, env_id, info_override):
"""Test DataCollector wrapper and Minari dataset creation."""
def test_record_infos_collector_env(dataset_id, env_id, info_override):
"""Test DataCollector wrapper and Minari dataset creation including infos."""
# dataset_id = "cartpole-test-v0"
# delete the test dataset if it already exists
local_datasets = minari.list_local_datasets()
Expand All @@ -195,10 +195,6 @@ def test_generate_dataset_with_collector_env_infos(dataset_id, env_id, info_over
while not terminated and not truncated:
action = env.action_space.sample() # User-defined policy function
_, _, terminated, truncated, _ = env.step(action)
if terminated or truncated:
assert not env._buffer[-1]
else:
assert env._buffer[-1]

env.reset()

Expand Down

0 comments on commit 98af413

Please sign in to comment.