Skip to content

Commit

Permalink
Merge pull request #5146 from NREL/adjust_python_measure_templates
Browse files Browse the repository at this point in the history
Fix typo in ReportingMeasure template measure.py + use pathlib.Path in tests
  • Loading branch information
jmarrec authored Apr 15, 2024
2 parents d2f0bdd + 28f6109 commit c6dd282
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ def test_good_argument_values(self):
assert zone.getString(0).get() == "New Zone"

# save the workspace to test output directory
output_file_path = openstudio.toPath(str(Path(__file__).parent.absolute() / "output" / "test_output.idf"))
output_file_path = Path(__file__).parent.absolute() / "output" / "test_output.idf"
workspace.save(output_file_path, True)
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_good_argument_values(self):

# load the test model
translator = openstudio.osversion.VersionTranslator()
path = openstudio.toPath(str(Path(__file__).parent.absolute() / "example_model.osm"))
path = Path(__file__).parent.absolute() / "example_model.osm"
model = translator.loadModel(path)
assert model.is_initialized()
model = model.get()
Expand Down Expand Up @@ -124,5 +124,5 @@ def test_good_argument_values(self):
assert num_spaces_final == num_spaces_seed + 1

# save the model to test output directory
output_file_path = openstudio.toPath(str(Path(__file__).parent.absolute() / "output" / "test_output.osm"))
output_file_path = Path(__file__).parent.absolute() / "output" / "test_output.osm"
model.save(output_file_path, True)
4 changes: 2 additions & 2 deletions src/utilities/bcl/templates/ReportingMeasure/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def arguments(self, model: openstudio.model.Model):

report_drybulb_temp = openstudio.measure.OSArgument.makeBoolArgument("report_drybulb_temp", True)
report_drybulb_temp.setDisplayName("Add output variables for Drybulb Temperature")
report_drybulb_temp.setDescription("Will add drybulb temp and report min/mix value in html.")
report_drybulb_temp.setDescription("Will add drybulb temp and report min/max values in html.")
report_drybulb_temp.setValue(True)
args.append(report_drybulb_temp)

Expand Down Expand Up @@ -269,7 +269,7 @@ def format_dt(dt):
</tr>
<tr>
<th scope="row">Maximum Site Outdoor Air Drybulb Temperature</th>
<td>{min(vals):.1f}</td>
<td>{max(vals):.1f}</td>
<td>C</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def setup_test(
request_model = rt.translateWorkspace(workspace)

translator = openstudio.osversion.VersionTranslator()
model = translator.loadModel(openstudio.toPath(str(model_in_path)))
model = translator.loadModel(model_in_path)
assert model.is_initialized()
model = model.get()
model.addObjects(request_model.objects())
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_with_drybulb_temp(self):
argument_map["report_drybulb_temp"] = report_drybulb_temp

# temp set path so idf_output_requests work
runner.setLastOpenStudioModelPath(openstudio.toPath(str(MODEL_IN_PATH_DEFAULT)))
runner.setLastOpenStudioModelPath(MODEL_IN_PATH_DEFAULT)

# get the energyplus output requests, this will be done automatically by OS App and PAT
idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
Expand All @@ -138,9 +138,9 @@ def test_with_drybulb_temp(self):
assert TestReportingMeasureName.sql_path(test_name).exists()

# set up runner, this will happen automatically when measure is run in PAT or OpenStudio
runner.setLastOpenStudioModelPath(openstudio.toPath(str(model_out_path)))
runner.setLastEpwFilePath(openstudio.toPath(str(epw_path)))
runner.setLastEnergyPlusSqlFilePath(openstudio.toPath(str(TestReportingMeasureName.sql_path(test_name))))
runner.setLastOpenStudioModelPath(model_out_path)
runner.setLastEpwFilePath(epw_path)
runner.setLastEnergyPlusSqlFilePath(TestReportingMeasureName.sql_path(test_name))

# delete the output if it exists
report_path = TestReportingMeasureName.report_path(test_name)
Expand Down Expand Up @@ -191,7 +191,7 @@ def test_without_drybulb_temp(self):
argument_map["report_drybulb_temp"] = report_drybulb_temp

# temp set path so idf_output_requests work
runner.setLastOpenStudioModelPath(openstudio.toPath(str(MODEL_IN_PATH_DEFAULT)))
runner.setLastOpenStudioModelPath(MODEL_IN_PATH_DEFAULT)

# get the energyplus output requests, this will be done automatically by OS App and PAT
idf_output_requests = measure.energyPlusOutputRequests(runner, argument_map)
Expand All @@ -207,9 +207,9 @@ def test_without_drybulb_temp(self):
assert TestReportingMeasureName.sql_path(test_name).exists()

# set up runner, this will happen automatically when measure is run in PAT or OpenStudio
runner.setLastOpenStudioModelPath(openstudio.toPath(str(model_out_path)))
runner.setLastEpwFilePath(openstudio.toPath(str(epw_path)))
runner.setLastEnergyPlusSqlFilePath(openstudio.toPath(str(TestReportingMeasureName.sql_path(test_name))))
runner.setLastOpenStudioModelPath(model_out_path)
runner.setLastEpwFilePath(epw_path)
runner.setLastEnergyPlusSqlFilePath(TestReportingMeasureName.sql_path(test_name))

# delete the output if it exists
report_path = TestReportingMeasureName.report_path(test_name)
Expand Down

0 comments on commit c6dd282

Please sign in to comment.