Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions buildingspy/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
BuildingsPy Changelog
---------------------

Version 5.2.1, xxxx
^^^^^^^^^^^^^^^^^^^

- Updated regression tests to avoid blocking web server.
(https://github.com/lbl-srg/BuildingsPy/issues/605)

Version 5.2.0, March 14, 2025
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
22 changes: 14 additions & 8 deletions buildingspy/development/regressiontest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2222,8 +2222,8 @@ def _compareResults(self, data_idx, oldRefFulFilNam, y_sim, y_tra, refFilNam, an
noOldResults.append(varNam)
if len(errors) > 0:
self._reporter.writeError(
"{}: Errors during result verification.\n {}".format(
refFilNam, '\n '.join(errors)))
"{} has errors during result verification.\n {}".format(
model_name, '\n '.join(errors)))
# Compare the simulation statistics
# There are these cases:
# 1. The old reference results have no statistics, in which case new results may be written.
Expand Down Expand Up @@ -2261,7 +2261,9 @@ def _compareResults(self, data_idx, oldRefFulFilNam, y_sim, y_tra, refFilNam, an
print("(Close plot window to continue.)")
self._legacy_plot(y_sim, t_ref, y_ref, noOldResults, timOfMaxErr, matFilNam)
else:
self._funnel_plot(model_name)
idx = next(i for i, el in enumerate(self._comp_info) if el['model'] == model_name)
comp_data = self._comp_info[idx]['comparison']
Tester._funnel_plot(comp_data, self._PLOT_TEMPLATE)

while not (ans == "n" or ans == "y" or ans == "Y" or ans == "N"):
ans = input(" Enter: y(yes), n(no), Y(yes for all), N(no for all): ")
Expand All @@ -2272,11 +2274,10 @@ def _compareResults(self, data_idx, oldRefFulFilNam, y_sim, y_tra, refFilNam, an

return (updateReferenceData, (newTrajectories or newStatistics), ans)

def _funnel_plot(self, model_name, browser=None):
@staticmethod
def _funnel_plot(comp_data, plot_template):
"""Plot comparison results generated by pyfunnel."""

idx = next(i for i, el in enumerate(self._comp_info) if el['model'] == model_name)
comp_data = self._comp_info[idx]['comparison']
dict_var_info = defaultdict(list)
for iv, v in enumerate(comp_data['variables']):
dict_var_info[v].append({'group': comp_data['var_groups'][iv],
Expand All @@ -2300,18 +2301,23 @@ def _funnel_plot(self, model_name, browser=None):
(1 + max(0, max(comp_data['var_groups']) - max_plot_per100) / max_plot_per100)
err_plot_height = 0.18 * 100 / height
# Populate the plot template.
with open(self._PLOT_TEMPLATE, 'r') as f:
with open(plot_template, 'r') as f:
template = f.read()
content = re.sub(r'\$PAGE_TITLE', plot_title, template)
content = re.sub(r'\$TITLE', plot_title, content)
content = re.sub(r'\$DICT_VAR_INFO', json.dumps(dict_var_info), content)
content = re.sub(r'\$HEIGHT', '{}%'.format(height), content)
content = re.sub(r'\$ERR_PLOT_HEIGHT', str(err_plot_height), content)
# Launch the local server.
Tester._run_web_server(content, list_files)

@staticmethod
def _run_web_server(content, list_files):

server = pyfunnel.MyHTTPServer(('', 0), pyfunnel.CORSRequestHandler,
str_html=content, url_html='funnel')
# Start the browser instance.
server.browse(list_files, browser=browser)
server.browse(list_files, timeout=0, browser=None)

def _legacy_plot(self, y_sim, t_ref, y_ref, noOldResults, timOfMaxErr, model_name):
"""Plot comparison results generated by legacy comparison algorithm."""
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gitpython>=3.1.33; python_version>='3.8'
pytidylib==0.3.2
simplejson==3.16.0
six==1.14.0
pyfunnel==1.0.2
pyfunnel==1.0.3
PyYAML==6.0.1
cerberus==1.3.4

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
'pytidylib>=0.3.2',
'simplejson>=3.16',
'six>=1.14',
'pyfunnel>=1.0.2',
'pyfunnel>=1.0.3',
'PyYAML>=6.0.1',
'cerberus>=1.3.4',
],
Expand Down