Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariosmsk committed Apr 17, 2024
2 parents 1756c93 + 47a7776 commit cd2892d
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions epyt_flow/simulation/scenario_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,6 @@ def __adapt_to_network_changes(self):

self.__sensor_config = new_sensor_config

def __find_temporary_file(self) -> str:
# Sort files by time to find the temporary file created by EPANET
files = list(filter(lambda f: os.path.isfile(f) and "." not in f, os.listdir()))
files.sort(key=os.path.getmtime)

if len(files) == 0:
return None
else:
return files[::-1][0]

def close(self):
"""
Closes & unloads all resources and libraries.
Expand Down Expand Up @@ -1017,8 +1007,6 @@ def run_simulation_as_generator(self, hyd_export: str = None, verbose: bool = Fa
self.epanet_api.initializeHydraulicAnalysis(ToolkitConstants.EN_SAVE)
self.epanet_api.initializeQualityAnalysis(ToolkitConstants.EN_SAVE)

tmp_file = self.__find_temporary_file()

requested_time_step = self.epanet_api.getTimeHydraulicStep()
reporting_time_start = self.epanet_api.getTimeReportingStart()
reporting_time_step = self.epanet_api.getTimeReportingStep()
Expand Down Expand Up @@ -1115,13 +1103,8 @@ def run_simulation_as_generator(self, hyd_export: str = None, verbose: bool = Fa
if hyd_export is not None:
self.epanet_api.saveHydraulicFile(hyd_export)
except Exception as ex:
if tmp_file is not None:
os.remove(tmp_file) # Close temporary files before raising any exceptions
raise ex

if tmp_file is not None:
os.remove(tmp_file) # Close temporary files

def set_model_uncertainty(self, model_uncertainty: ModelUncertainty) -> None:
"""
Specifies the model uncertainties.
Expand Down

0 comments on commit cd2892d

Please sign in to comment.