Skip to content

Commit

Permalink
Keep all ExperimentBuilder tests in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
opcode81 committed Oct 24, 2023
1 parent b5a8915 commit 58466eb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 42 deletions.
41 changes: 0 additions & 41 deletions test/highlevel/test_discrete.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from test.highlevel.env_factory import ContinuousTestEnvFactory
from test.highlevel.env_factory import ContinuousTestEnvFactory, DiscreteTestEnvFactory

import pytest

from tianshou.highlevel.config import SamplingConfig
from tianshou.highlevel.experiment import (
A2CExperimentBuilder,
DDPGExperimentBuilder,
DiscreteSACExperimentBuilder,
DQNExperimentBuilder,
ExperimentConfig,
IQNExperimentBuilder,
PGExperimentBuilder,
PPOExperimentBuilder,
REDQExperimentBuilder,
Expand Down Expand Up @@ -47,3 +50,31 @@ def test_experiment_builder_continuous_default_params(builder_cls):
experiment = builder.build()
experiment.run("test")
print(experiment)


@pytest.mark.parametrize(
"builder_cls",
[
PPOExperimentBuilder,
A2CExperimentBuilder,
DQNExperimentBuilder,
DiscreteSACExperimentBuilder,
IQNExperimentBuilder,
],
)
def test_experiment_builder_discrete_default_params(builder_cls):
env_factory = DiscreteTestEnvFactory()
sampling_config = SamplingConfig(
num_epochs=1,
step_per_epoch=100,
num_train_envs=2,
num_test_envs=2,
)
builder = builder_cls(
experiment_config=ExperimentConfig(persistence_enabled=False),
env_factory=env_factory,
sampling_config=sampling_config,
)
experiment = builder.build()
experiment.run("test")
print(experiment)

0 comments on commit 58466eb

Please sign in to comment.