Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MY handler regression #478

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions reV/handlers/multi_year.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ def _parse_pass_through_dsets(self, dsets, pass_through_dsets):
pass_through_dsets : list
List of pass through datasets.
"""
with Resource(self.source_files[0]) as res:
all_dsets = res.datasets

if isinstance(dsets, str) and dsets == 'PIPELINE':
files = parse_previous_status(self._dirout, ModuleName.MULTI_YEAR)
with Resource(files[0]) as res:
dsets = res.datasets
dsets = all_dsets

if "lcoe_fcr" in dsets:
for dset in LCOE_REQUIRED_OUTPUTS:
if dset not in pass_through_dsets and dset in dsets:
if dset not in pass_through_dsets and dset in all_dsets:
pass_through_dsets.append(dset)

if "dc_ac_ratio" in dsets:
Expand Down
40 changes: 39 additions & 1 deletion tests/test_handlers_multiyear.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import tempfile
import traceback
from copy import deepcopy

import h5py
import numpy as np
Expand All @@ -16,7 +17,8 @@

from reV import TESTDATADIR
from reV.cli import main
from reV.handlers.multi_year import MultiYear
from reV.generation.base import LCOE_REQUIRED_OUTPUTS
from reV.handlers.multi_year import MultiYear, MultiYearGroup
from reV.handlers.outputs import Outputs
from reV.utilities import ModuleName

Expand Down Expand Up @@ -371,6 +373,42 @@ def test_my_stdev(dset, group):
compare_arrays(my_std, dset_std, "Saved STDEV")


def test_pass_through_dsets():
"""test that LCOE dsets correctly added to pass through. """
test_pass_through_dsets = ["capital_cost", "reg_mult",
"fixed_operating_cost", "system_capacity",
"system_capacity_ac", "fixed_charge_rate",
"variable_operating_cost", "dc_ac_ratio"]

existing_dsets = list(LCOE_REQUIRED_OUTPUTS) + ["dc_ac_ratio"]

with tempfile.TemporaryDirectory() as temp:
temp_h5_files = [os.path.join(temp, os.path.basename(fp))
for fp in H5_FILES]
for fp, fp_temp in zip(H5_FILES, temp_h5_files):
shutil.copy(fp, fp_temp)

for fp in temp_h5_files:
for i, dset in enumerate(existing_dsets):
with h5py.File(fp, 'a') as f:
shape = f['meta'].shape
arr = np.arange(shape[0]) * (i + 1)
f.create_dataset(dset, shape, data=arr)

group = {"dsets": ["cf_profile", "cf_profile_ac", "cf_mean",
"cf_mean_ac", "ghi_mean", "lcoe_fcr", "ac", "dc",
"clipped_power"],
"source_dir": temp,
"source_prefix": "gen_ri_pv",
"pass_through_dsets": deepcopy(test_pass_through_dsets)}

group = MultiYearGroup("test", ".", **group)
test_ptd = group.pass_through_dsets

assert test_pass_through_dsets != test_ptd
assert all(dset in test_ptd for dset in LCOE_REQUIRED_OUTPUTS)


def execute_pytest(capture='all', flags='-rapP'):
"""Execute module as pytest with detailed summary report.

Expand Down
Loading