-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c8211d
commit 68ee8cb
Showing
4 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
tests/unittests/data/components_for_scenarization_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright (c) 2024, RTE (https://www.rte-france.com) | ||
# | ||
# See AUTHORS.txt | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
# | ||
# This file is part of the Antares project. | ||
study: | ||
nodes: | ||
- id: N | ||
model: node | ||
|
||
components: | ||
- id: G | ||
model: sd-generator | ||
parameters: | ||
- name: cost | ||
scenario-group: cost-group | ||
type: timeseries | ||
timeseries: gen-costs | ||
- name: p_max | ||
type: constant | ||
value: 100 | ||
- id: D | ||
model: demand | ||
scenario-group: load | ||
parameters: | ||
- name: demand | ||
type: timeseries | ||
timeseries: loads | ||
|
||
connections: | ||
- component1: N | ||
port_1: injection_port | ||
component2: D | ||
port_2: injection_port | ||
|
||
- component1: N | ||
port_1: injection_port | ||
component2: G | ||
port_2: injection_port | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
50 100 | ||
50 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright (c) 2024, RTE (https://www.rte-france.com) | ||
# | ||
# See AUTHORS.txt | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
# | ||
# This file is part of the Antares project. | ||
|
||
from pathlib import Path | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from andromede.study import DataBase | ||
from andromede.study.data import ComponentParameterIndex | ||
from andromede.study.parsing import parse_yaml_components | ||
from andromede.study.resolve_components import build_scenarized_data_base | ||
|
||
|
||
@pytest.fixture | ||
def database(data_dir: Path) -> DataBase: | ||
builder = pd.DataFrame( | ||
{ | ||
"name": [ | ||
"load", | ||
"load", | ||
"load", | ||
"load", | ||
"cost-group", | ||
"cost-group", | ||
"cost-group", | ||
"cost-group", | ||
], | ||
"year": [0, 1, 2, 3, 0, 1, 2, 3], | ||
"scenario": [0, 1, 0, 1, 0, 0, 1, 1], | ||
} | ||
) | ||
builder = builder.reset_index() | ||
|
||
study_path = data_dir / "components_for_scenarization_test.yml" | ||
ts_path = data_dir | ||
with study_path.open() as components: | ||
return build_scenarized_data_base( | ||
parse_yaml_components(components), builder, ts_path | ||
) | ||
|
||
|
||
def test_scenarized_data_base(database): | ||
cost_index = ComponentParameterIndex("G", "cost") | ||
assert database.get_value(cost_index, 0, 0) == 100 | ||
assert database.get_value(cost_index, 0, 1) == 100 | ||
assert database.get_value(cost_index, 0, 2) == 200 | ||
assert database.get_value(cost_index, 0, 3) == 200 | ||
|
||
load_index = ComponentParameterIndex("D", "demand") | ||
assert database.get_value(load_index, 0, 0) == 50 | ||
assert database.get_value(load_index, 0, 1) == 100 | ||
assert database.get_value(load_index, 0, 2) == 50 | ||
assert database.get_value(load_index, 0, 3) == 100 |