Skip to content

Commit

Permalink
test_evaluate_time_series corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
vargastat committed Apr 8, 2024
1 parent 9f3eec8 commit 646fb54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/andromede/study/resolve_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ def _evaluate_time_series(file_ts: Optional[str]) -> Dict[TimeScenarioIndex, flo
df = pd.read_csv(path, header=None)
values = df.values
arr_split = [x[0].split() for x in values]
for i, sublist in enumerate(arr_split):
for j, element in enumerate(sublist):
index = TimeScenarioIndex(time=j, scenario=i)
time_series[index] = float(element)
num_rows = len(arr_split)
num_cols = len(arr_split[0])
for time in range(num_rows):
for scenario in range(num_cols):
index = TimeScenarioIndex(time=time, scenario=scenario)
time_series[index] = float(arr_split[time][scenario])
except FileNotFoundError:
print(f"Error: File {file_ts} does not exists")
return time_series
4 changes: 2 additions & 2 deletions tests/unittests/study/test_components_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def test_evaluate_time_series(data_dir: Path):
gen_costs = _evaluate_time_series(str(txt_file))
expected_timeseries = {
TimeScenarioIndex(0, 0): 100,
TimeScenarioIndex(0, 1): 50,
TimeScenarioIndex(1, 0): 200,
TimeScenarioIndex(1, 0): 50,
TimeScenarioIndex(0, 1): 200,
TimeScenarioIndex(1, 1): 100,
}
assert gen_costs == expected_timeseries

0 comments on commit 646fb54

Please sign in to comment.