Skip to content

Commit a8dfbff

Browse files
Unit test re: NREL#192
1 parent bc3fa2e commit a8dfbff

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
INPUT, Gradient 1, triangular, 36, 41, 44
2+
OUTPUT, Average Net Electricity Production
3+
OUTPUT, Electricity breakeven price
4+
ITERATIONS, 3

tests/geophires_monte_carlo_tests/test_geophires_monte_carlo.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
import re
34
import unittest
45
from pathlib import Path
56

@@ -107,6 +108,34 @@ def test_monte_carlo_result_ordering(self):
107108

108109
self.assertDictEqual(result_json_obj, result.result['output'])
109110

111+
def test_geophires_monte_carlo_single_input(self):
112+
"""https://github.com/NREL/GEOPHIRES-X/issues/192"""
113+
114+
client = GeophiresMonteCarloClient()
115+
num_iterations = 3
116+
117+
input_file_path: Path = self._get_arg_file_path('GEOPHIRES-example1.txt')
118+
mc_settings_file_path: Path = self._get_arg_file_path('MC_GEOPHIRES_Settings_file-3.txt')
119+
result: MonteCarloResult = client.get_monte_carlo_result(
120+
MonteCarloRequest(
121+
SimulationProgram.GEOPHIRES,
122+
input_file_path,
123+
mc_settings_file_path,
124+
)
125+
)
126+
self.assertIsNotNone(result)
127+
self.assertIsNotNone(result.output_file_path)
128+
129+
with open(result.output_file_path) as f:
130+
result_content = f.read()
131+
self.assertIn(
132+
'Average Net Electricity Production, Electricity breakeven price, Gradient 1',
133+
result_content,
134+
)
135+
gradient_inputs = re.compile(r'\(Gradient\s1\:[3-4][0-9]\.[0-9]+').findall(result_content)
136+
self.assertEqual(num_iterations, len(gradient_inputs))
137+
self.assertEqual(num_iterations, len(set(gradient_inputs))) # verify unique values were generated
138+
110139
def test_hip_ra_monte_carlo(self):
111140
client = GeophiresMonteCarloClient()
112141

0 commit comments

Comments
 (0)