Skip to content

Commit 63e228b

Browse files
fix category row label case
1 parent a5a98f4 commit 63e228b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/geophires_x/EconomicsSamCashFlow.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def is_only_commas(s: str) -> bool:
116116
# mapped.
117117
continue
118118

119-
if re.match(r'^([A-Z \(\)\-\:]+)$', row_label) or re.match(r'^([A-Za-z \-]+\:)$', row_label):
119+
if _is_category_row_label(row_label):
120120
category_row(row_label)
121121
continue
122122

@@ -131,6 +131,10 @@ def is_only_commas(s: str) -> bool:
131131
return _clean_profile(profile)
132132

133133

134+
def _is_category_row_label(row_label: str) -> bool:
135+
return re.match(r'^([A-Z \(\)\-\:]+)$', row_label) or re.match(r'^([A-Z][A-Za-z \-]+\:)$', row_label)
136+
137+
134138
def _clean_profile(profile: list[list[Any]]) -> list[list[Any]]:
135139
# Collapse consecutive blank rows
136140
previous_line_was_blank = False

tests/geophires_x_tests/test_economics_sam.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
)
2222

2323
# noinspection PyProtectedMember
24-
from geophires_x.EconomicsSamCashFlow import _clean_profile
24+
from geophires_x.EconomicsSamCashFlow import _clean_profile, _is_category_row_label
2525
from geophires_x_client import GeophiresInputParameters
2626
from geophires_x_client import GeophiresXClient
2727
from geophires_x_client import GeophiresXResult
@@ -162,6 +162,10 @@ def test_clean_profile(self):
162162
],
163163
)
164164

165+
def test_is_category_row_label(self):
166+
self.assertTrue(_is_category_row_label('OPERATING ACTIVITIES'))
167+
self.assertFalse(_is_category_row_label('plus PBI if not available for debt service:'))
168+
165169
def test_sig_figs(self):
166170
self.assertListEqual(_sig_figs([1.14, 2.24], 2), [1.1, 2.2])
167171
self.assertListEqual(_sig_figs((1.14, 2.24), 2), [1.1, 2.2])

0 commit comments

Comments
 (0)