Skip to content

Commit b539ae9

Browse files
committed
adressing issue rte-france#591 which was a non issue
1 parent 543cbdb commit b539ae9

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

grid2op/tests/test_issue_591.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright (c) 2024, RTE (https://www.rte-france.com)
2+
# See AUTHORS.txt
3+
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
4+
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
5+
# you can obtain one at http://mozilla.org/MPL/2.0/.
6+
# SPDX-License-Identifier: MPL-2.0
7+
# This file is part of Grid2Op, Grid2Op a testbed platform to model sequential decision making in power systems.
8+
9+
import os
10+
import warnings
11+
import unittest
12+
import grid2op
13+
from grid2op.utils import ScoreL2RPN2020
14+
from grid2op.Agent import DoNothingAgent
15+
16+
17+
class Issue591Tester(unittest.TestCase):
18+
def setUp(self) -> None:
19+
self.max_iter = 10
20+
return super().setUp()
21+
22+
def test_issue_591(self):
23+
with warnings.catch_warnings():
24+
warnings.filterwarnings("ignore")
25+
env = grid2op.make("rte_case5_example", test=True)
26+
27+
ch_patterns = env.chronics_handler.reset()
28+
ch_patterns = ch_patterns.tolist()
29+
ch_patterns = ch_patterns[17:19]
30+
31+
nb_scenario = len(ch_patterns)
32+
agent = DoNothingAgent(env.action_space)
33+
handler = env.chronics_handler
34+
handler.set_filter(lambda path: path in ch_patterns)
35+
chronics = handler.reset()
36+
37+
38+
scorer_2020 = ScoreL2RPN2020(
39+
env,
40+
max_step=1,
41+
nb_scenario=1,
42+
env_seeds=[0 for _ in range(1)],
43+
agent_seeds=[0 for _ in range(1)],
44+
)
45+
scorer_2020.clear_all()
46+
scorer_2020 = ScoreL2RPN2020(
47+
env,
48+
max_step=self.max_iter,
49+
nb_scenario=nb_scenario,
50+
env_seeds=[0 for _ in range(nb_scenario)],
51+
agent_seeds=[0 for _ in range(nb_scenario)],
52+
)
53+
try:
54+
score_2020 = scorer_2020.get(agent)
55+
finally:
56+
scorer_2020.clear_all()
57+
for scen_path, score, ts_survived, total_ts in zip(ch_patterns, *score_2020):
58+
assert total_ts == self.max_iter, f"wrong number of ts {total_ts} vs {self.max_iter}"
59+
60+
61+
if __name__ == "__main__":
62+
unittest.main()

grid2op/tests/test_issue_593.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023, RTE (https://www.rte-france.com)
1+
# Copyright (c) 2024, RTE (https://www.rte-france.com)
22
# See AUTHORS.txt
33
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
44
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,

0 commit comments

Comments
 (0)