Esempio n. 1
0
    def test_compute_without_score(self):
        """test that i can compute and erase the results afterwards"""
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore")
            with make("rte_case5_example", test=True) as env:
                stats = EpisodeStatistics(env, "test")
                stats.compute(nb_scenario=2, max_step=10, pbar=False)
                # i can access it
                prods, ids_ = stats.get("prod_p")
                assert prods.shape == (22, 2), "error on the prods shape"
                assert ids_.shape == (22, 1), "error on the ids shape"
                with self.assertRaises(RuntimeError):
                    scores, ids_ = stats.get("scores")

                # i can clear everything
                stats.clear_all()
                assert not os.path.exists(os.path.join(env.get_path_env(), stats.get_name_dir("test")))
Esempio n. 2
0
    def test_compute_with_score(self):
        """test that i can compute and erase the results afterwards"""
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore")
            with make("rte_case5_example", test=True) as env:
                stats = EpisodeStatistics(env, "test")
                stats.compute(nb_scenario=2, max_step=10, pbar=False, scores_func=L2RPNSandBoxScore)
                # i can access it
                scores, ids_ = stats.get(EpisodeStatistics.SCORES)
                assert scores.shape == (20,), "error on the score shape"
                assert ids_.shape == (20, 1), "error on the ids shape"

                scores, ids_ = stats.get("scores")
                assert scores.shape == (20,), "error on the score shape"
                assert ids_.shape == (20, 1), "error on the ids shape"
                # i can clear everything
                stats.clear_all()
                assert not os.path.exists(os.path.join(env.get_path_env(), stats.get_name_dir("test")))
Esempio n. 3
0
 def test_compute_erase(self):
     """test that i can compute and erase the results afterwards"""
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         with make("rte_case5_example", test=True) as env:
             stats = EpisodeStatistics(env, "test")
             stats.compute(nb_scenario=1, max_step=10, pbar=False)
             # the file have been created
             assert os.path.exists(os.path.join(env.get_path_env(), stats.get_name_dir("test")))
             # i can access it
             aor_, ids_ = stats.get("a_or")
             assert aor_.shape == (11, 8)
             # i can clear the data of individual episode
             stats.clear_episode_data()
             assert not os.path.exists(os.path.join(env.get_path_env(), stats.get_name_dir("test"), "00"))
             # i can clear everything
             stats.clear_all()
             assert not os.path.exists(os.path.join(env.get_path_env(), stats.get_name_dir("test")))