Skip to content

Commit

Permalink
Add test for LCOE dsets to get added to pass through
Browse files Browse the repository at this point in the history
  • Loading branch information
ppinchuk committed Oct 23, 2024
1 parent df1eee5 commit cfa53bd
Showing 1 changed file with 39 additions and 1 deletion.
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

0 comments on commit cfa53bd

Please sign in to comment.