Skip to content

Commit eb32851

Browse files
fix client parsing of SAM cash flow profile
1 parent fddcf29 commit eb32851

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/geophires_x_client/geophires_x_result.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,6 @@ def extract_table_header(lines: list) -> list:
738738
def _get_sam_cash_flow_profile(self) -> list[Any]:
739739
profile_name = 'SAM CASH FLOW PROFILE'
740740

741-
def _get_sam_cash_flow_profile_lines():
742-
s1 = f'* {profile_name} *'
743-
s2 = '-' * 50
744-
return ''.join(self._lines).split(s1)[1].split(s2)[0].split(s2)[0] # [5:]
745-
746741
try:
747742
s1 = f'* {profile_name} *'
748743
profile_text = ''.join(self._lines).split(s1)[1]
@@ -767,12 +762,12 @@ def _get_sam_cash_flow_profile_entry_display_to_entry_val(entry_display: str) ->
767762
if entry_display is None:
768763
return None
769764

770-
ed_san = entry_display.replace(',', '') if type(entry_display) is str else entry_display
765+
ed_san = entry_display.strip().replace(',', '') if type(entry_display) is str else entry_display
771766
if is_float(ed_san):
772767
if not math.isnan(float(ed_san)):
773-
return float(ed_san) if not is_int(ed_san) else int(ed_san)
768+
return float(ed_san) if not is_int(ed_san) else int(float(ed_san))
774769

775-
return entry_display
770+
return entry_display.strip()
776771

777772
def _extract_addons_style_table_data(self, lines: list):
778773
"""TODO consolidate with _get_data_from_profile_lines"""

tests/test_geophires_x_client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,3 +592,13 @@ def test_parse_economic_model(self):
592592
result_legacy_em._lines = [' Economic Model = BICYCLE']
593593
em_legacy = result_legacy_em._get_equal_sign_delimited_field('Economic Model')
594594
self.assertEqual(em_legacy, 'BICYCLE')
595+
596+
def test_parse_sam_cash_flow_profile(self):
597+
result = GeophiresXResult(self._get_test_file_path('examples/example_SAM-single-owner-PPA.out'))
598+
em = result.result['ECONOMIC PARAMETERS']['Economic Model']
599+
self.assertEqual(em, 'SAM Single Owner PPA')
600+
self.assertIn('SAM CASH FLOW PROFILE', result.result)
601+
602+
cash_flow = result.result['SAM CASH FLOW PROFILE']
603+
self.assertIsNotNone(cash_flow)
604+
self.assertListEqual([''] + [f'Year {y}' for y in range(21)], cash_flow[0])

0 commit comments

Comments
 (0)