Search is not available for this dataset
repo stringlengths 2 152 ⌀ | file stringlengths 15 239 | code stringlengths 0 58.4M | file_length int64 0 58.4M | avg_line_length float64 0 1.81M | max_line_length int64 0 12.7M | extension_type stringclasses 364
values |
|---|---|---|---|---|---|---|
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/__init__.py | """Collection of dummy environments used in testing."""
from tests.fixtures.envs.dummy.base import DummyEnv
from tests.fixtures.envs.dummy.dummy_box_env import DummyBoxEnv
from tests.fixtures.envs.dummy.dummy_dict_env import DummyDictEnv
from tests.fixtures.envs.dummy.dummy_discrete_2d_env import DummyDiscrete2DEnv
fro... | 980 | 45.714286 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/base.py | """Dummy environment for testing purpose."""
import gym
class DummyEnv(gym.Env):
"""Base dummy environment.
Args:
random (bool): If observations are randomly generated or not.
obs_dim (iterable): Observation space dimension.
action_dim (iterable): Action space dimension.
"""
... | 1,125 | 21.078431 | 69 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/dummy_box_env.py | """Dummy gym.spaces.Box environment for testing purpose."""
import gym
import numpy as np
from tests.fixtures.envs.dummy import DummyEnv
class DummyBoxEnv(DummyEnv):
"""A dummy gym.spaces.Box environment.
Args:
random (bool): If observations are randomly generated or not.
obs_dim (iterable):... | 1,841 | 25.314286 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/dummy_dict_env.py | """Dummy akro.Dict environment for testing purpose."""
import akro
import gym
import numpy as np
from garage.envs import EnvSpec
from tests.fixtures.envs.dummy import DummyEnv
class DummyDictEnv(DummyEnv):
"""A dummy akro.Dict environment with predefined inner spaces.
Args:
random (bool): If observa... | 3,583 | 28.866667 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/dummy_discrete_2d_env.py | import gym
import numpy as np
from tests.fixtures.envs.dummy import DummyEnv
class DummyDiscrete2DEnv(DummyEnv):
"""A dummy discrete environment."""
def __init__(self, random=True):
super().__init__(random)
self.shape = (2, 2)
self._observation_space = gym.spaces.Box(
low... | 1,276 | 26.76087 | 66 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/dummy_discrete_env.py | import gym
import numpy as np
from tests.fixtures.envs.dummy import DummyEnv
class DummyDiscreteEnv(DummyEnv):
"""A dummy discrete environment."""
def __init__(self, obs_dim=(1, ), action_dim=1, random=True):
super().__init__(random, obs_dim, action_dim)
@property
def observation_space(self... | 1,142 | 27.575 | 66 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/dummy_discrete_pixel_env.py | """A dummy discrete pixel env."""
from unittest import mock
import gym
import numpy as np
from tests.fixtures.envs.dummy import DummyEnv
class DummyDiscretePixelEnv(DummyEnv):
"""A dummy discrete pixel environment.
It follows Atari game convention, where actions are 'NOOP', 'FIRE', ...
It also contains... | 4,401 | 29.150685 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/dummy_discrete_pixel_env_baselines.py | import gym
import numpy as np
from tests.fixtures.envs.dummy import DummyEnv
class LazyFrames(object):
def __init__(self, frames):
"""
LazyFrames class from baselines.
Openai baselines use this class for FrameStack environment
wrapper. It is used for testing garage.envs.wrappers.... | 1,821 | 27.46875 | 73 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/dummy_multitask_box_env.py | """Dummy gym.spaces.Box environment for testing purpose."""
from tests.fixtures.envs.dummy import DummyBoxEnv
from tests.helpers import choices
class DummyMultiTaskBoxEnv(DummyBoxEnv):
"""A dummy gym.spaces.Box multitask environment.
Args:
random (bool): If observations are randomly generated or not.... | 1,579 | 24.901639 | 69 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/dummy/dummy_reward_box_env.py | from tests.fixtures.envs.dummy import DummyBoxEnv
class DummyRewardBoxEnv(DummyBoxEnv):
"""A dummy box environment."""
def __init__(self, random=True):
super().__init__(random)
def step(self, action):
"""Step the environment."""
if action == 0:
reward = 10
els... | 417 | 23.588235 | 68 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/wrappers/__init__.py | from tests.fixtures.envs.wrappers.reshape_observation import ReshapeObservation
__all__ = ['ReshapeObservation']
| 114 | 27.75 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/envs/wrappers/reshape_observation.py | """Reshaping Observation for gym.Env."""
import gym
import numpy as np
class ReshapeObservation(gym.Wrapper):
"""
Reshaping Observation wrapper for gym.Env.
This wrapper convert the observations into the given shape.
Args:
env (gym.Env): The environment to be wrapped.
shape (list[int... | 1,449 | 29.851064 | 74 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/experiment/__init__.py | from tests.fixtures.experiment.fixture_experiment import fixture_exp
__all__ = ['fixture_exp']
| 96 | 23.25 | 68 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/experiment/fixture_experiment.py | """A dummy experiment fixture."""
from garage.envs import GarageEnv
from garage.experiment import LocalTFRunner
from garage.np.baselines import LinearFeatureBaseline
from garage.tf.algos import VPG
from garage.tf.policies import CategoricalMLPPolicy
# pylint: disable=missing-return-type-doc
def fixture_exp(snapshot_c... | 1,569 | 33.888889 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/__init__.py | """Mock models for testing."""
from tests.fixtures.models.simple_categorical_gru_model import (
SimpleCategoricalGRUModel)
from tests.fixtures.models.simple_categorical_lstm_model import (
SimpleCategoricalLSTMModel)
from tests.fixtures.models.simple_categorical_mlp_model import (
SimpleCategoricalMLPModel)... | 1,518 | 37.948718 | 76 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_categorical_gru_model.py | """Simple CategoricalGRUModel for testing."""
import tensorflow_probability as tfp
from tests.fixtures.models.simple_gru_model import SimpleGRUModel
class SimpleCategoricalGRUModel(SimpleGRUModel):
"""Simple CategoricalGRUModel for testing.
Args:
output_dim (int): Dimension of the network output.
... | 1,853 | 33.333333 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_categorical_lstm_model.py | """Simple CategoricalLSTMModel for testing."""
import tensorflow_probability as tfp
from tests.fixtures.models.simple_lstm_model import SimpleLSTMModel
class SimpleCategoricalLSTMModel(SimpleLSTMModel):
"""Simple CategoricalLSTMModel for testing.
Args:
output_dim (int): Dimension of the network outp... | 2,243 | 33.523077 | 74 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_categorical_mlp_model.py | """Simple CategoricalMLPModel for testing."""
import tensorflow_probability as tfp
from tests.fixtures.models.simple_mlp_model import SimpleMLPModel
class SimpleCategoricalMLPModel(SimpleMLPModel):
"""Simple CategoricalMLPModel for testing.
Args:
output_dim (int): Dimension of the network output.
... | 1,256 | 26.933333 | 65 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_cnn_model.py | """Simple CNNModel for testing."""
import tensorflow as tf
from garage.tf.models import Model
class SimpleCNNModel(Model):
"""Simple CNNModel for testing.
Args:
filters (Tuple[Tuple[int, Tuple[int, int]], ...]): Number and dimension
of filters. For example, ((3, (3, 5)), (32, (3, 3))) me... | 3,211 | 40.714286 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_cnn_model_with_max_pooling.py | """Simple CNNModel with max pooling for testing."""
import tensorflow as tf
from garage.tf.models import Model
class SimpleCNNModelWithMaxPooling(Model):
"""Simple CNNModel with max pooling for testing.
Args:
filters (Tuple[Tuple[int, Tuple[int, int]], ...]): Number and dimension
of filt... | 4,287 | 44.136842 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_gaussian_cnn_model.py | import tensorflow as tf
from garage.tf.distributions import DiagonalGaussian
from garage.tf.models import Model
class SimpleGaussianCNNModel(Model):
"""Simple GaussianCNNModel for testing."""
def __init__(self,
output_dim,
name='SimpleGaussianCNNModel',
*ar... | 1,026 | 33.233333 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_gaussian_gru_model.py | import tensorflow as tf
from garage.tf.distributions import DiagonalGaussian
from garage.tf.models import Model
class SimpleGaussianGRUModel(Model):
"""Simple GaussianGRUModel for testing."""
def __init__(self,
output_dim,
hidden_dim,
name='SimpleGaussianGR... | 1,754 | 30.339286 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_gaussian_lstm_model.py | import tensorflow as tf
from garage.tf.distributions import DiagonalGaussian
from garage.tf.models import Model
class SimpleGaussianLSTMModel(Model):
"""Simple GaussianLSTMModel for testing."""
def __init__(self,
output_dim,
hidden_dim,
name='SimpleGaussian... | 2,121 | 32.15625 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_gaussian_mlp_model.py | import numpy as np
import tensorflow as tf
from garage.tf.distributions import DiagonalGaussian
from garage.tf.models import Model
class SimpleGaussianMLPModel(Model):
"""Simple GaussianMLPModel for testing."""
def __init__(self,
output_dim,
name='SimpleGaussianMLPModel',
... | 1,023 | 32.032258 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_gru_model.py | import tensorflow as tf
from garage.tf.models import Model
class SimpleGRUModel(Model):
"""Simple GRUModel for testing."""
def __init__(self,
output_dim,
hidden_dim,
name='SimpleGRUModel',
*args,
**kwargs):
super().... | 1,420 | 31.295455 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_lstm_model.py | import tensorflow as tf
from garage.tf.models import Model
class SimpleLSTMModel(Model):
"""Simple LSTMModel for testing."""
def __init__(self,
output_dim,
hidden_dim,
name='SimpleLSTMModel',
*args,
**kwargs):
super... | 1,884 | 29.901639 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_mlp_merge_model.py | import tensorflow as tf
from garage.tf.models import Model
class SimpleMLPMergeModel(Model):
"""Simple MLPMergeModel for testing."""
def __init__(self, output_dim, name=None, *args, **kwargs):
super().__init__(name)
self.output_dim = output_dim
def network_input_spec(self):
"""N... | 640 | 29.52381 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/models/simple_mlp_model.py | import tensorflow as tf
from garage.tf.models import Model
class SimpleMLPModel(Model):
"""Simple MLPModel for testing."""
def __init__(self, output_dim, name=None, *args, **kwargs):
super().__init__(name)
self.output_dim = output_dim
def _build(self, obs_input, name=None):
retu... | 506 | 28.823529 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/policies/__init__.py | from tests.fixtures.policies.dummy_policy import (DummyPolicy,
DummyPolicyWithoutVectorized)
from tests.fixtures.policies.dummy_recurrent_policy import (
DummyRecurrentPolicy)
__all__ = [
'DummyPolicy', 'DummyRecurrentPolicy', 'DummyPolicyWithoutVectorized'
]
| 319 | 34.555556 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/policies/dummy_policy.py | """Dummy Policy for algo tests.."""
import numpy as np
from garage.np.policies import Policy
from tests.fixtures.distributions import DummyDistribution
class DummyPolicy(Policy):
"""Dummy Policy.
Args:
env_spec (garage.envs.env_spec.EnvSpec): Environment specification.
"""
def __init__(sel... | 2,494 | 21.889908 | 76 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/policies/dummy_recurrent_policy.py | """Dummy Recurrent Policy for algo tests."""
import numpy as np
from garage.np.policies import Policy
from tests.fixtures.distributions import DummyDistribution
class DummyRecurrentPolicy(Policy):
"""Dummy Recurrent Policy.
Args:
env_spec (garage.envs.env_spec.EnvSpec): Environment specification.
... | 1,509 | 22.230769 | 75 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/q_functions/__init__.py | from tests.fixtures.q_functions.simple_q_function import SimpleQFunction
__all__ = ['SimpleQFunction']
| 104 | 25.25 | 72 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/q_functions/simple_q_function.py | """Simple QFunction for testing."""
import tensorflow as tf
from garage.tf.q_functions import QFunction
from tests.fixtures.models import SimpleMLPModel
class SimpleQFunction(QFunction):
"""Simple QFunction for testing.
Args:
env_spec (garage.envs.env_spec.EnvSpec): Environment specification.
... | 1,810 | 25.632353 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/regressors/__init__.py | from tests.fixtures.regressors.simple_gaussian_cnn_regressor import (
SimpleGaussianCNNRegressor)
from tests.fixtures.regressors.simple_gaussian_mlp_regressor import (
SimpleGaussianMLPRegressor)
from tests.fixtures.regressors.simple_mlp_regressor import (SimpleMLPRegressor)
__all__ = [
'SimpleGaussianCNNR... | 388 | 34.363636 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/regressors/simple_gaussian_cnn_regressor.py | """Simple GaussianCNNRegressor for testing."""
import numpy as np
import tensorflow as tf
from garage.tf.regressors import StochasticRegressor
from tests.fixtures.models import SimpleGaussianCNNModel
class SimpleGaussianCNNRegressor(StochasticRegressor):
"""Simple GaussianCNNRegressor for testing.
Args:
... | 3,931 | 28.125926 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/regressors/simple_gaussian_mlp_regressor.py | """Simple GaussianMLPRegressor for testing."""
import numpy as np
import tensorflow as tf
from garage.tf.regressors import StochasticRegressor
from tests.fixtures.models import SimpleGaussianMLPModel
class SimpleGaussianMLPRegressor(StochasticRegressor):
"""Simple GaussianMLPRegressor for testing.
Args:
... | 3,931 | 28.125926 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/regressors/simple_mlp_regressor.py | """Simple MLPRegressor for testing."""
import tensorflow as tf
from garage.tf.regressors import Regressor
from tests.fixtures.models import SimpleMLPModel
class SimpleMLPRegressor(Regressor):
"""Simple MLPRegressor for testing.
Args:
input_shape (tuple[int]): Input shape of the training data.
... | 2,876 | 26.141509 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/sampler/__init__.py | """Fixtures for testing samplers."""
from tests.fixtures.sampler.ray_fixtures import (ray_local_session_fixture,
ray_session_fixture)
__all__ = ['ray_local_session_fixture', 'ray_session_fixture']
| 248 | 34.571429 | 75 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/sampler/ray_fixtures.py | """Pytest fixtures for intializing ray during ray related tests."""
import pytest
import ray
@pytest.fixture(scope='function')
def ray_local_session_fixture():
"""Initializes Ray and shuts down Ray in local mode.
Yields:
None: Yield is for purposes of pytest module style.
All statements b... | 1,328 | 28.533333 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/tf/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/fixtures/tf/algos/dummy_off_policy_algo.py | """A dummy off-policy algorithm."""
from garage.np.algos import RLAlgorithm
class DummyOffPolicyAlgo(RLAlgorithm):
"""A dummy off-policy algorithm."""
def init_opt(self):
"""Initialize the optimization procedure."""
def train(self, runner):
"""Obtain samplers and start actual training fo... | 1,058 | 26.868421 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/test_dtypes.py | import akro
import gym.spaces
import numpy as np
import pytest
from garage import TimeStep
from garage import TimeStepBatch
from garage import TrajectoryBatch
from garage.envs import EnvSpec
@pytest.fixture
def traj_data():
# spaces
obs_space = gym.spaces.Box(low=1,
high=np.inf... | 25,538 | 34.970423 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/test_functions.py | """Test root level functions in garage."""
import csv
import math
import tempfile
import akro
import dowel
from dowel import logger, tabular
import numpy as np
import pytest
import tensorflow as tf
import torch
from garage import _Default, make_optimizer
from garage import log_multitask_performance, log_performance, ... | 9,585 | 40.141631 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_env_spec.py | import pickle
import akro
from garage.envs.env_spec import EnvSpec
class TestEnvSpec:
def test_pickleable(self):
env_spec = EnvSpec(akro.Box(-1, 1, (1, )), akro.Box(-2, 2, (2, )))
round_trip = pickle.loads(pickle.dumps(env_spec))
assert round_trip
assert round_trip.action_space =... | 418 | 26.933333 | 74 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_garage_env.py | from gym.wrappers import TimeLimit
import numpy as np
import pytest
from garage.envs import EnvSpec, GarageEnv
from garage.envs.grid_world_env import GridWorldEnv
from garage.np.policies import ScriptedPolicy
class TestGarageEnv:
def test_wraps_env_spec(self):
garage_env = GarageEnv(env_name='Pendulum-v... | 3,337 | 35.681319 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_grid_world_env.py | import pickle
from garage.envs.grid_world_env import GridWorldEnv
from tests.helpers import step_env
class TestGridWorldEnv:
def test_pickleable(self):
env = GridWorldEnv(desc='8x8')
round_trip = pickle.loads(pickle.dumps(env))
assert round_trip
assert round_trip.start_state == en... | 637 | 24.52 | 56 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_half_cheetah_meta_envs.py | import pickle
import pytest
try:
# pylint: disable=unused-import
import mujoco_py # noqa: F401
except ImportError:
pytest.skip('To use mujoco-based features, please install garage[mujoco].',
allow_module_level=True)
except Exception: # pylint: disable=broad-except
pytest.skip(
... | 1,169 | 29.789474 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_multi_env_wrapper.py | """Tests for garage.envs.multi_env_wrapper"""
import akro
import numpy as np
import pytest
from garage.envs import GarageEnv
from garage.envs.multi_env_wrapper import (MultiEnvWrapper,
round_robin_strategy,
uniform_random_strategy)
... | 8,707 | 39.129032 | 111 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_normalized_env.py | import pickle
import numpy as np
from garage.envs import PointEnv
from garage.envs.normalized_env import NormalizedEnv
from tests.helpers import step_env
class TestNormalizedEnv:
def test_pickleable(self):
inner_env = PointEnv(goal=(1., 2.))
env = NormalizedEnv(inner_env, scale_reward=10.)
... | 902 | 28.129032 | 66 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_normalized_gym.py | import gym
from garage.envs import GarageEnv, normalize
class TestNormalizedGym:
def setup_method(self):
self.env = GarageEnv(
normalize(gym.make('Pendulum-v0'),
normalize_reward=True,
normalize_obs=True,
flatten_obs=True))
... | 1,444 | 29.104167 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_point_env.py | import pickle
import numpy as np
from garage.envs.point_env import PointEnv
from tests.helpers import step_env
class TestPointEnv:
def test_pickleable(self):
env = PointEnv()
round_trip = pickle.loads(pickle.dumps(env))
assert round_trip
step_env(round_trip)
env.close()
... | 1,505 | 22.904762 | 53 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_rl2_env.py | from garage.envs import PointEnv
from garage.tf.algos.rl2 import RL2Env
class TestRL2Env:
# pylint: disable=unsubscriptable-object
def test_observation_dimension(self):
env = PointEnv()
wrapped_env = RL2Env(PointEnv())
assert wrapped_env.spec.observation_space.shape[0] == (
... | 728 | 37.368421 | 76 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/test_task_onehot_wrapper.py | """Tests for garage.envs.TaskOnehotWrapper"""
import numpy as np
from garage.envs import PointEnv, TaskOnehotWrapper
class TestSingleWrappedEnv:
def setup_method(self):
self.env = PointEnv()
self.base_len = len(self.env.reset())
self.n_total_tasks = 5
self.task_index = 1
... | 2,263 | 35.516129 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/box2d/parser/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/dm_control/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/dm_control/test_dm_control_env.py | import collections
from copy import copy
import pickle
import dm_control.mujoco
import dm_control.suite
import pytest
from garage.envs.dm_control import DmControlEnv
from tests.helpers import step_env
@pytest.mark.mujoco
class TestDmControlEnv:
def test_can_step(self):
domain_name, task_name = dm_contr... | 3,617 | 35.545455 | 72 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/dm_control/test_dm_control_tf_policy.py | from dm_control.suite import ALL_TASKS
import pytest
from garage.envs import GarageEnv
from garage.envs.dm_control import DmControlEnv
from garage.experiment import LocalTFRunner
from garage.np.baselines import LinearFeatureBaseline
from garage.tf.algos import TRPO
from garage.tf.policies import GaussianMLPPolicy
from... | 1,195 | 27.47619 | 70 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/test_atari_env.py | import numpy as np
from garage.envs.wrappers import AtariEnv
from tests.fixtures.envs.dummy import DummyDiscretePixelEnvBaselines
class TestFireReset:
def test_atari_env(self):
env = DummyDiscretePixelEnvBaselines()
env_wrapped = AtariEnv(env)
obs = env.reset()
obs_wrapped = env_w... | 618 | 29.95 | 68 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/test_clip_reward.py | from garage.envs.wrappers import ClipReward
from tests.fixtures.envs.dummy import DummyRewardBoxEnv
class TestClipReward:
def test_clip_reward(self):
# reward = 10 when action = 0, otherwise -10
env = DummyRewardBoxEnv(random=True)
env_wrap = ClipReward(env)
env.reset()
env... | 632 | 25.375 | 55 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/test_episodic_life.py | import numpy as np
from garage.envs.wrappers import EpisodicLife
from tests.fixtures.envs.dummy import DummyDiscretePixelEnv
class TestEpisodicLife:
def test_episodic_life_reset(self):
env = EpisodicLife(DummyDiscretePixelEnv())
obs = env.reset()
# env has reset
assert np.array_e... | 888 | 27.677419 | 76 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/test_fire_reset.py | import numpy as np
from garage.envs.wrappers import FireReset
from tests.fixtures.envs.dummy import DummyDiscretePixelEnv
class TestFireReset:
def test_fire_reset(self):
env = DummyDiscretePixelEnv()
env_wrap = FireReset(env)
obs = env.reset()
obs_wrap = env_wrap.reset()
... | 695 | 32.142857 | 77 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/test_grayscale_env.py | import gym.spaces
import numpy as np
import pytest
from garage.envs.wrappers import Grayscale
from tests.fixtures.envs.dummy import DummyDiscretePixelEnv
class TestGrayscale:
def setup_method(self):
self.env = DummyDiscretePixelEnv(random=False)
self.env_g = Grayscale(DummyDiscretePixelEnv(random... | 1,947 | 32.586207 | 86 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/test_max_and_skip.py | import numpy as np
from garage.envs.wrappers import MaxAndSkip
from tests.fixtures.envs.dummy import DummyDiscretePixelEnv
class TestMaxAndSkip:
def setup_method(self):
self.env = DummyDiscretePixelEnv(random=False)
self.env_wrap = MaxAndSkip(DummyDiscretePixelEnv(random=False), skip=4)
def ... | 1,171 | 29.842105 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/test_noop.py | import numpy as np
from garage.envs.wrappers import Noop
from tests.fixtures.envs.dummy import DummyDiscretePixelEnv
class TestNoop:
def test_noop(self):
env = Noop(DummyDiscretePixelEnv(), noop_max=3)
for _ in range(1000):
env.reset()
assert 1 <= env.env.step_called <= 3... | 933 | 32.357143 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/test_resize_env.py | import gym.spaces
import numpy as np
import pytest
from garage.envs.wrappers import Resize
from tests.fixtures.envs.dummy import DummyDiscrete2DEnv
class TestResize:
def setup_method(self):
self.width = 16
self.height = 16
self.env = DummyDiscrete2DEnv()
self.env_r = Resize(
... | 1,385 | 32 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/envs/wrappers/test_stack_frames_env.py | import gym.spaces
import numpy as np
import pytest
from garage.envs.wrappers import StackFrames
from tests.fixtures.envs.dummy import DummyDiscrete2DEnv
class TestStackFrames:
def setup_method(self):
self.n_frames = 4
self.env = DummyDiscrete2DEnv(random=False)
self.env_s = StackFrames(
... | 1,949 | 34.454545 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/test_deterministic.py | """Tests for deterministic.py"""
import random
import numpy as np
import tensorflow as tf
import torch
from garage.experiment import deterministic
def test_deterministic_pytorch():
"""Test deterministic behavior of PyTorch"""
deterministic.set_seed(111)
rand_tensor = torch.rand((5, 5))
deterministic... | 2,567 | 37.909091 | 76 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/test_experiment.py | import os
import pathlib
import shutil
import subprocess
import sys
import tempfile
import textwrap
import pytest
from garage.experiment.experiment import run_experiment, wrap_experiment
def dummy_func(*_):
pass
def test_default_log_dir():
# Because this test uses the default log directory, if any other t... | 18,241 | 32.349177 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/test_experiment_wrapper.py | import base64
import pickle
import pytest
from garage.experiment import SnapshotConfig
from garage.experiment.experiment_wrapper import run_experiment
def method_call(snapshot_config, variant_data, from_dir, from_epoch):
assert isinstance(snapshot_config, SnapshotConfig)
assert snapshot_config.snapshot_dir ... | 1,276 | 26.76087 | 74 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/test_local_runner.py | import gym
import pytest
import torch
from garage.envs import GarageEnv, normalize
from garage.experiment import deterministic, LocalRunner
from garage.plotter import Plotter
from garage.sampler import LocalSampler
from garage.torch.algos import PPO
from garage.torch.policies import GaussianMLPPolicy
from garage.torch... | 3,274 | 29.045872 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/test_meta_evaluator.py | import csv
import tempfile
import cloudpickle
from dowel import CsvOutput, logger, tabular
import numpy as np
import pytest
import tensorflow as tf
from garage.envs import GarageEnv, PointEnv
from garage.experiment import LocalTFRunner, MetaEvaluator, SnapshotConfig
from garage.experiment.deterministic import set_see... | 6,549 | 34.405405 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/test_resume.py | import tempfile
import numpy as np
import tensorflow as tf
from garage.experiment import LocalTFRunner, SnapshotConfig
from tests.fixtures import TfGraphTestCase
from tests.fixtures.experiment import fixture_exp
class TestResume(TfGraphTestCase):
def setup_method(self):
super().setup_method()
s... | 1,901 | 36.294118 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/test_snapshotter.py | from os import path as osp
import pickle
import tempfile
import pytest
from garage.experiment import Snapshotter
configurations = [('all', {
'itr_1.pkl': 0,
'itr_2.pkl': 1
}), ('last', {
'params.pkl': 1
}), ('gap', {
'itr_2.pkl': 1
}), ('gap_and_last', {
'itr_2.pkl': 1,
'params.pkl': 1
}), ('... | 1,552 | 28.301887 | 73 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/test_snapshotter_integration.py | import tempfile
import pytest
from garage.envs import GarageEnv
from garage.experiment import SnapshotConfig, Snapshotter
from garage.tf.algos import VPG
from garage.tf.policies import CategoricalMLPPolicy
from tests.fixtures import TfGraphTestCase
from tests.fixtures.experiment import fixture_exp
configurations = [... | 1,558 | 33.644444 | 73 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/experiment/test_task_sampler.py | import functools
import unittest.mock
import numpy as np
import pytest
try:
# pylint: disable=unused-import
import mujoco_py # noqa: F401
except ImportError:
pytest.skip('To use mujoco-based features, please install garage[mujoco].',
allow_module_level=True)
except Exception: # pylint: di... | 3,239 | 32.402062 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/misc/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/misc/test_tensor_utils.py | """
This script creates a test that tests functions in garage.misc.tensor_utils.
"""
import numpy as np
from garage.envs import GarageEnv
from garage.misc.tensor_utils import concat_tensor_dict_list
from garage.misc.tensor_utils import explained_variance_1d
from garage.misc.tensor_utils import normalize_pixel_batch
f... | 3,783 | 38.831579 | 76 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/np/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/np/algos/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/np/algos/test_cem.py | import pytest
from garage.envs import GarageEnv
from garage.experiment import LocalTFRunner
from garage.np.algos import CEM
from garage.np.baselines import LinearFeatureBaseline
from garage.sampler import OnPolicyVectorizedSampler
from garage.tf.policies import CategoricalMLPPolicy
from tests.fixtures import snapshot_... | 1,310 | 32.615385 | 74 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/np/algos/test_cma_es.py | from garage.envs import GarageEnv
from garage.experiment import LocalTFRunner
from garage.np.algos import CMAES
from garage.np.baselines import LinearFeatureBaseline
from garage.sampler import OnPolicyVectorizedSampler
from garage.tf.policies import CategoricalMLPPolicy
from tests.fixtures import snapshot_config, TfGra... | 1,284 | 35.714286 | 74 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/np/exploration_strategies/test_add_gaussian_noise.py | """Tests for epsilon greedy policy."""
import pickle
import numpy as np
import pytest
from garage.np.exploration_policies import AddGaussianNoise
from tests.fixtures.envs.dummy import DummyBoxEnv
@pytest.fixture
def env():
return DummyBoxEnv()
class ConstantPolicy:
"""Simple policy for testing."""
de... | 1,804 | 28.112903 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/np/exploration_strategies/test_epsilon_greedy_policy.py | """Tests for epsilon greedy policy."""
import pickle
import numpy as np
from garage.np.exploration_policies import EpsilonGreedyPolicy
from tests.fixtures.envs.dummy import DummyDiscreteEnv
class SimplePolicy:
"""Simple policy for testing."""
def __init__(self, env_spec):
self.env_spec = env_spec
... | 2,397 | 34.791045 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/np/policies/test_fixed_policy.py | import numpy as np
import pytest
from garage.np.policies import FixedPolicy
def test_vectorization_multi_raises():
policy = FixedPolicy(None, np.array([1, 2, 3]))
with pytest.raises(ValueError):
policy.reset([True, True])
with pytest.raises(ValueError):
policy.get_actions(np.array([0, 0])... | 650 | 28.590909 | 66 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/np/policies/test_scripted_policy.py | from garage.np.policies import ScriptedPolicy
class TestScriptedPolicy:
def setup_method(self):
self.sp = ScriptedPolicy(scripted_actions=[1], agent_env_infos={0: 1})
"""
potentially add more tests down the line
"""
def test_pass_codecov(self):
self.sp.get_action(0)
self... | 341 | 20.375 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/replay_buffer/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/replay_buffer/test_her_replay_buffer.py | import pickle
import numpy as np
import pytest
from garage.envs import GarageEnv
from garage.replay_buffer import HERReplayBuffer
from tests.fixtures.envs.dummy import DummyDictEnv
class TestHerReplayBuffer:
def setup_method(self):
self.env = GarageEnv(DummyDictEnv())
self.obs = self.env.reset(... | 3,484 | 38.602273 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/replay_buffer/test_path_buffer.py | # pylint: disable=protected-access
import numpy as np
import pytest
from garage.replay_buffer import PathBuffer
from tests.fixtures.envs.dummy import DummyDiscreteEnv
class TestPathBuffer:
def test_add_path_dtype(self):
env = DummyDiscreteEnv()
obs = env.reset()
replay_buffer = PathBuffe... | 2,197 | 32.815385 | 71 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/sampler/__init__.py | 0 | 0 | 0 | py | |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/sampler/test_is_sampler.py | import unittest.mock
import gym
import pytest
from garage.envs import GarageEnv, normalize
from garage.experiment import LocalTFRunner
from garage.np.baselines import LinearFeatureBaseline
from garage.sampler import ISSampler
from garage.tf.algos import TRPO
from garage.tf.policies import GaussianMLPPolicy
from tests... | 3,100 | 37.7625 | 76 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/sampler/test_local_sampler.py | from unittest.mock import Mock
import numpy as np
import pytest
from garage.envs import GarageEnv
from garage.envs import PointEnv
from garage.envs.grid_world_env import GridWorldEnv
from garage.experiment.task_sampler import SetTaskSampler
from garage.np.policies import FixedPolicy, ScriptedPolicy
from garage.sample... | 6,625 | 36.647727 | 78 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/sampler/test_multiprocessing_sampler.py | import pickle
from unittest.mock import Mock
import numpy as np
import pytest
from garage.envs import GarageEnv
from garage.envs import PointEnv
from garage.envs.grid_world_env import GridWorldEnv
from garage.experiment.task_sampler import SetTaskSampler
from garage.np.policies import FixedPolicy, ScriptedPolicy
from... | 7,930 | 37.5 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/sampler/test_off_policy_vectorized_sampler_integration.py | import gym
import numpy as np
import pytest
import tensorflow as tf
from garage.envs import GarageEnv, normalize
from garage.experiment import LocalTFRunner
from garage.np.exploration_policies import AddOrnsteinUhlenbeckNoise
from garage.replay_buffer import PathBuffer
from garage.sampler import OffPolicyVectorizedSam... | 3,841 | 43.16092 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/sampler/test_on_policy_vectorized_sampler.py | import gym
import pytest
from garage.envs import GarageEnv
from garage.experiment import LocalTFRunner
from garage.np.baselines import LinearFeatureBaseline
from garage.sampler import OnPolicyVectorizedSampler
from garage.tf.algos import REPS
from garage.tf.policies import CategoricalMLPPolicy
from tests.fixtures impo... | 1,476 | 35.02439 | 73 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/sampler/test_ray_batched_sampler.py | """Tests for ray_batched_sampler."""
from unittest.mock import Mock
import numpy as np
import pytest
import ray
from garage.envs import GarageEnv
from garage.envs import PointEnv
from garage.envs.grid_world_env import GridWorldEnv
from garage.experiment.task_sampler import SetTaskSampler
from garage.np.policies impor... | 5,551 | 39.525547 | 79 | py |
CSD-locomotion | CSD-locomotion-master/garaged/tests/garage/sampler/test_rl2_worker.py | from garage.envs import GarageEnv
from garage.tf.algos.rl2 import RL2Worker
from tests.fixtures import TfGraphTestCase
from tests.fixtures.envs.dummy import DummyBoxEnv
from tests.fixtures.policies import DummyPolicy
class TestRL2Worker(TfGraphTestCase):
def test_rl2_worker(self):
env = GarageEnv(DummyBo... | 715 | 33.095238 | 51 | py |