Skip to content

Commit

Permalink
HBNOutput.py -- small cleanup
Browse files Browse the repository at this point in the history
regression_base.py -- options for cleaner looking report
  • Loading branch information
PaulDudaRESPEC committed Oct 20, 2023
1 parent 7e64691 commit 4c8a30c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
3 changes: 2 additions & 1 deletion HSP2tools/HBNOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def read_data(self) -> None:
dfname = f'{operation}_{activity}_{id:03d}_{tcode}'
if self.simulation_duration_count == 0:
self.simulation_duration_count = len(times)
df = DataFrame(rows, index=times, columns=mapn[operation, id, activity]).sort_index('index')
# df = DataFrame(rows, index=times, columns=mapn[operation, id, activity]).sort_index('index')
df = DataFrame(rows, index=times, columns=mapn[operation, id, activity]).sort_index()
self.data_frames.append(df)

self.summaryindx.append(dfname)
Expand Down
34 changes: 24 additions & 10 deletions tests/convert/regression_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,31 @@ def make_html_report(self, results_dict:Dict[OperationsTuple,ResultsTuple]) -> s
def make_html_comp_row(self, con:str, no_data_hsp2:bool,
no_data_hspf:bool, match:bool, diff:float) -> str:
"""populates each constituents rows"""
if no_data_hsp2 or no_data_hspf:
html = f'<tr><td>-</td><td>{con}</td><td>NA</td><td>NA</td><td>'
html += f'{"Not in HSP2" if no_data_hsp2 else ""}<br>'
html += f'{"Not in HSPF" if no_data_hspf else ""}'
html += f'</td></tr>\n'
diffsOnly= False
eliminateNotIns = True
html = ''
if diffsOnly:
if no_data_hsp2 or no_data_hspf:
pass
else:
if match:
pass
else:
match_symbol = f'<span style="font-weight:bold;color:red">X</span>'
html = f'<tr><td>-</td><td>{con}</td><td>{diff}</td><td>{match_symbol}</td><td></td></tr>\n'
else:
if match:
match_symbol = f'<span style="font-weight:bold;color:green">&#10003;</span>'
if no_data_hsp2 or no_data_hspf:
if not eliminateNotIns:
html = f'<tr><td>-</td><td>{con}</td><td>NA</td><td>NA</td><td>'
html += f'{"Not in HSP2" if no_data_hsp2 else ""}<br>'
html += f'{"Not in HSPF" if no_data_hspf else ""}'
html += f'</td></tr>\n'
else:
match_symbol = f'<span style="font-weight:bold;color:red">X</span>'
html = f'<tr><td>-</td><td>{con}</td><td>{diff}</td><td>{match_symbol}</td><td></td></tr>\n'
if match:
match_symbol = f'<span style="font-weight:bold;color:green">&#10003;</span>'
else:
match_symbol = f'<span style="font-weight:bold;color:red">X</span>'
html = f'<tr><td>-</td><td>{con}</td><td>{diff}</td><td>{match_symbol}</td><td></td></tr>\n'
return html

def write_html(self, file:str, html:str) -> None:
Expand Down Expand Up @@ -164,7 +178,7 @@ def check_con(self, params:OperationsTuple) -> ResultsTuple:
if len(ts_hspf.shape) > 1:
ts_hspf = ts_hspf.iloc[:,0]

tolerance = 1e-2
tolerance = 1e-2 # may want to change default to max(abs(ts_hsp2.values.min()), abs(ts_hsp2.values.max())) * 1e-3
# if heat related term, compute special tolerance
if constituent == 'IHEAT' or constituent == 'ROHEAT' or constituent.startswith('OHEAT') or \
constituent == 'QSOLAR' or constituent == 'QLONGW' or constituent == 'QEVAP' or \
Expand Down

0 comments on commit 4c8a30c

Please sign in to comment.