Skip to content
Merged
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
7 changes: 7 additions & 0 deletions buildingspy/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
BuildingsPy Changelog
---------------------

Version 5.2.1, ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Updated pyfunnel to version 2.0.1 to fix plotting issues.
With this change, Python 2 is no longer supported.
(https://github.com/lbl-srg/BuildingsPy/issues/599)

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

Expand Down
2 changes: 1 addition & 1 deletion buildingspy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.0
5.2.1
49 changes: 25 additions & 24 deletions buildingspy/development/regressiontest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
# [email protected] 2011-02-23
#######################################################
#
from collections import defaultdict
from contextlib import contextmanager
import difflib
import fnmatch
import functools
import glob
import io
Expand All @@ -24,19 +20,24 @@
import sys
import tempfile
import time
import webbrowser
from collections import defaultdict
from contextlib import contextmanager

# Third-party module or package imports.
import numpy as np
import simplejson

# Code repository sub-package imports.
import pyfunnel
from buildingspy.development import error_dictionary_openmodelica
from buildingspy.development import error_dictionary_optimica
from buildingspy.development import error_dictionary_dymola
from buildingspy.io.outputfile import Reader
from buildingspy.io.postprocess import Plotter

import buildingspy.io.outputfile as of
import buildingspy.io.reporter as rep
from buildingspy.development import (
error_dictionary_dymola,
error_dictionary_openmodelica,
error_dictionary_optimica,
)
from buildingspy.io.outputfile import Reader
from buildingspy.io.postprocess import Plotter


def runSimulation(worDir, cmd):
Expand Down Expand Up @@ -2237,6 +2238,13 @@ def _compareResults(self, data_idx, oldRefFulFilNam, y_sim, y_tra, refFilNam, an
newStatistics = self._check_statistics(
old_results, y_tra, stage, newTrajectories, newStatistics, model_name)

if newTrajectories:
if self._comp_tool == 'legacy':
print("(Close plot window to continue.)")
self._legacy_plot(y_sim, t_ref, y_ref, noOldResults, timOfMaxErr, matFilNam)
else:
self._funnel_plot(model_name)

# If the users selected "Y" or "N" (to not accept or reject any new results) in previous tests,
# or if the script is run in batch mode, then don't plot the results.
# If we found an error, plot the results, and ask the user to accept or
Expand All @@ -2256,13 +2264,6 @@ def _compareResults(self, data_idx, oldRefFulFilNam, y_sim, y_tra, refFilNam, an
print(
f" update reference files with new {self._color_BOLD}trajectories{self._color_ERROR}?{self._color_ENDC}")

if newTrajectories:
if self._comp_tool == 'legacy':
print("(Close plot window to continue.)")
self._legacy_plot(y_sim, t_ref, y_ref, noOldResults, timOfMaxErr, matFilNam)
else:
self._funnel_plot(model_name)

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 Down Expand Up @@ -2311,7 +2312,7 @@ def _funnel_plot(self, model_name, browser=None):
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, browser=browser, timeout=60)

def _legacy_plot(self, y_sim, t_ref, y_ref, noOldResults, timOfMaxErr, model_name):
"""Plot comparison results generated by legacy comparison algorithm."""
Expand Down Expand Up @@ -3880,7 +3881,7 @@ def _get(model, key, data):
return 0

with open(self._statistics_log, 'r') as f:
staVal = simplejson.loads(f.read())
staVal = json.loads(f.read())
data = []
for case in staVal['testCase']:
if 'translate' in case:
Expand All @@ -3902,7 +3903,7 @@ def _get(model, key, data):
temp['simulation']['state_events'] = case['simulate']['state_events'] if 'state_events' in case['simulate'] else 0
temp['simulation']['success'] = case['simulate']['result']
data.append(temp)
dataJson = simplejson.dumps(data)
dataJson = json.dumps(data)
return dataJson

def run(self):
Expand Down Expand Up @@ -4135,7 +4136,7 @@ def run(self):
# For Dymola: store available simulation info into
# self._comp_info used for reporting.
val = self._run_simulation_info()
self._comp_info = simplejson.loads(val)
self._comp_info = json.loads(val)

r = self._checkReferencePoints(ans)
if r != 0: # In case of comparison error. Comparison warnings are handled
Expand All @@ -4153,8 +4154,8 @@ def run(self):
if not self._skip_verification or self._rewrite_configuration_file:
# For OpenModelica and OPTIMICA: store available translation and simulation info
# into self._comp_info used for reporting or for rewriting the configuration file.
with open(self._simulator_log_file, 'r') as f:
self._comp_info = simplejson.loads(f.read())
with open(self._simulator_log_file, 'r', encoding='utf-8-sig') as f:
self._comp_info = json.loads(f.read())

if not self._skip_verification:
r = self._checkReferencePoints(ans='N')
Expand Down
Loading