コード例 #1
0
    def test_reset_no_same_length(self):
        """
        Tests that the reset method uses the original ring length when the
        range is set to None.
        """
        # setup env_params with not range
        env_params = deepcopy(self.env_params)
        env_params.additional_params["ring_length"] = None

        # create the environment
        env = WaveAttenuationEnv(sim_params=self.sim_params,
                                 scenario=self.scenario,
                                 env_params=env_params)

        # reset the network several times and check its length
        self.assertEqual(env.k.scenario.length(), LOOP_PARAMS["length"])
        env.reset()
        self.assertEqual(env.k.scenario.length(), LOOP_PARAMS["length"])
        env.reset()
        self.assertEqual(env.k.scenario.length(), LOOP_PARAMS["length"])
コード例 #2
0
    def test_reset(self):
        """
        Tests that the reset method creating new ring lengths within the
        requested range.
        """
        # set a random seed to ensure the network lengths are always the same
        # during testing
        random.seed(9001)

        # create the environment
        env = WaveAttenuationEnv(sim_params=self.sim_params,
                                 scenario=self.scenario,
                                 env_params=self.env_params)

        # reset the network several times and check its length
        self.assertEqual(env.k.scenario.length(), 230)
        env.reset()
        self.assertEqual(env.k.scenario.length(), 239)
        env.reset()
        self.assertEqual(env.k.scenario.length(), 224)