Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test d3rlpy #252

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ testing = [

integrations = [
"torchrl",
"agilerl>=1.0.6"
"agilerl>=1.0.6",
"d3rlpy"
]

[project.urls]
Expand Down
38 changes: 38 additions & 0 deletions tests/integrations/test_d3rlpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import numpy as np
import pytest

import minari


pytest.importorskip("d3rlpy")
from d3rlpy.datasets import get_minari # noqa: E402


def test_d3rlpy():
dataset_name = "D4RL/door/human-v2"
minari_dataset = minari.load_dataset(dataset_name, download=True)
dataset, env = get_minari(dataset_name)

env_spec1, env_spec2 = minari_dataset.recover_environment().spec, env.spec
assert env_spec1 is not None
assert env_spec2 is not None
assert env_spec1.id == env_spec2.id
assert env_spec1.kwargs == env_spec2.kwargs

d3rlpy_episode = dataset.episodes[0]
minari_episode = minari_dataset[0]

assert len(d3rlpy_episode) == len(minari_episode)

for step_idx in range(len(d3rlpy_episode)):
assert env.observation_space.contains(d3rlpy_episode.observations[step_idx])
assert env.action_space.contains(d3rlpy_episode.actions[step_idx])

assert np.all(
d3rlpy_episode.observations[step_idx]
== minari_episode.observations[step_idx]
)
assert np.all(
d3rlpy_episode.actions[step_idx] == minari_episode.actions[step_idx]
)
assert d3rlpy_episode.rewards[step_idx] == minari_episode.rewards[step_idx]
Loading