Skip to content

Commit

Permalink
Refactor CSV writing logic for test result files.
Browse files Browse the repository at this point in the history
Simplified and standardized the CSV generation to dynamically handle variable file inputs and their components. Adjusted indentation and added conditional logic to improve readability and maintainability throughout. Also ensured compatibility with specific environments in the minitest configuration.
rh0dium committed Jan 8, 2025
1 parent d0ef10e commit d2ba348
Showing 3 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -21,4 +21,4 @@
require 'minitest/autorun'
require 'minitest/reporters'
require 'minitest/reporters/spec_reporter' # Needed when run via OS CLI
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new # spec-like progress
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new unless ENV['RM_INFO'] # spec-like progress
21 changes: 13 additions & 8 deletions workflow/tests/resnet_other_test.rb
Original file line number Diff line number Diff line change
@@ -61,15 +61,20 @@ def test_resnet_hers_iad_home_auto_generation
end
assert(all_results.size > 0)

# Write results to csv
# Write results to CSV
CSV.open(test_results_csv, 'w') do |csv|
csv << ['Component', 'Test 1 Results', 'Test 2 Results', 'Test 3 Results', 'Test 4 Results']
all_results['01-L100.xml'].keys.each do |component|
csv << [component,
all_results['01-L100.xml'][component],
all_results['02-L100.xml'][component],
all_results['03-L304.xml'][component],
all_results['04-L324.xml'][component]]
# Write the header row with filenames
header = ['Component'] + all_results.keys
csv << header

# Dynamically get the first file's components
first_file = all_results.keys.first

# Iterate over the components in the first file
all_results[first_file].keys.each do |component|
# Gather results from all files for the current component
row = [component] + all_results.keys.map { |file| all_results[file][component] }
csv << row
end
end
puts "Wrote results to #{test_results_csv}."
25 changes: 15 additions & 10 deletions workflow/tests/util.rb
Original file line number Diff line number Diff line change
@@ -310,15 +310,20 @@ def _test_resnet_hers_reference_home_auto_generation(test_name, dir_name, versio
end
assert(all_results.size > 0)

# Write results to csv
# Write results to CSV
CSV.open(test_results_csv, 'w') do |csv|
csv << ['Component', 'Test 1 Results', 'Test 2 Results', 'Test 3 Results', 'Test 4 Results']
all_results['01-L100.xml'].keys.each do |component|
csv << [component,
all_results['01-L100.xml'][component],
all_results['02-L100.xml'][component],
all_results['03-L304.xml'][component],
all_results['04-L324.xml'][component]]
# Write the header row with filenames
header = ['Component'] + all_results.keys
csv << header

# Dynamically get the first file's components
first_file = all_results.keys.first

# Iterate over the components in the first file
all_results[first_file].keys.each do |component|
# Gather results from all files for the current component
row = [component] + all_results.keys.map { |file| all_results[file][component] }
csv << row
end
end
puts "Wrote results to #{test_results_csv}."
@@ -458,8 +463,8 @@ def _get_reference_home_components(hpxml, test_num, version)
results['Window SHGCo'] = win_shgc_htg.round(2)
assert_equal(win_shgc_htg, win_shgc_clg)
else
results['Window SHGCo (heating)'] = win_shgc_htg.round(2)
results['Window SHGCo (cooling)'] = win_shgc_clg.round(2)
results['Window SHGCo (heating)'] = win_shgc_htg.round(2)
results['Window SHGCo (cooling)'] = win_shgc_clg.round(2)
end

# Infiltration

0 comments on commit d2ba348

Please sign in to comment.