Skip to content

Commit da628f9

Browse files
parse result numbers with commas
1 parent b56a6f4 commit da628f9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/geophires_x_client/geophires_x_result.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,11 @@ def _get_data_from_profile_lines(self, profile_lines):
681681
return data
682682

683683
def _parse_number(self, number_str, field='string') -> int | float:
684-
if number_str == 'N/A':
684+
if number_str == 'N/A' or number_str is None:
685685
return None
686686

687687
try:
688+
number_str = number_str.replace(',', '')
688689
if '.' in number_str:
689690
# TODO should probably ideally use decimal.Decimal to preserve precision,
690691
# i.e. 1.00 for USD instead of 1.0

tests/test_geophires_x_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,3 +528,7 @@ def test_parse_chp_percent_cost_allocation(self):
528528
def test_parse_annualized_capital_costs(self):
529529
result = GeophiresXResult(self._get_test_file_path('examples/example1_addons.out'))
530530
self.assertIsNotNone(result.result['CAPITAL COSTS (M$)']['Annualized capital costs']['value'])
531+
532+
def test_parse_number_with_commas(self):
533+
result = GeophiresXResult(self._get_test_file_path('examples/S-DAC-GT.out'))
534+
self.assertEqual(result.result['S_DAC_GT ECONOMICS']['Total Cost of Capture']['value'], 499_311_405.59)

0 commit comments

Comments
 (0)