Skip to content

Commit

Permalink
Unit test re: NREL#192
Browse files Browse the repository at this point in the history
  • Loading branch information
softwareengineerprogrammer committed Apr 30, 2024
1 parent bc3fa2e commit a8dfbff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
INPUT, Gradient 1, triangular, 36, 41, 44
OUTPUT, Average Net Electricity Production
OUTPUT, Electricity breakeven price
ITERATIONS, 3
29 changes: 29 additions & 0 deletions tests/geophires_monte_carlo_tests/test_geophires_monte_carlo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import re
import unittest
from pathlib import Path

Expand Down Expand Up @@ -107,6 +108,34 @@ def test_monte_carlo_result_ordering(self):

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

def test_geophires_monte_carlo_single_input(self):
"""https://github.com/NREL/GEOPHIRES-X/issues/192"""

client = GeophiresMonteCarloClient()
num_iterations = 3

input_file_path: Path = self._get_arg_file_path('GEOPHIRES-example1.txt')
mc_settings_file_path: Path = self._get_arg_file_path('MC_GEOPHIRES_Settings_file-3.txt')
result: MonteCarloResult = client.get_monte_carlo_result(
MonteCarloRequest(
SimulationProgram.GEOPHIRES,
input_file_path,
mc_settings_file_path,
)
)
self.assertIsNotNone(result)
self.assertIsNotNone(result.output_file_path)

with open(result.output_file_path) as f:
result_content = f.read()
self.assertIn(
'Average Net Electricity Production, Electricity breakeven price, Gradient 1',
result_content,
)
gradient_inputs = re.compile(r'\(Gradient\s1\:[3-4][0-9]\.[0-9]+').findall(result_content)
self.assertEqual(num_iterations, len(gradient_inputs))
self.assertEqual(num_iterations, len(set(gradient_inputs))) # verify unique values were generated

def test_hip_ra_monte_carlo(self):
client = GeophiresMonteCarloClient()

Expand Down

0 comments on commit a8dfbff

Please sign in to comment.