Skip to content

Commit

Permalink
Update test_upgrade_columns
Browse files Browse the repository at this point in the history
  • Loading branch information
afontani committed Jan 6, 2025
1 parent 1f5eac1 commit 0d7fb07
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions test/test_analysis_tools.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,36 @@ def test_baseline_columns
end

def test_upgrades_columns
['national', 'testing'].each do |project|
results_csvs = Dir[File.join(@buildstock_directory, "buildstockbatch/project_#{project}/#{project}_upgrades/results_csvs/results_up*.csv")]
assert_equal(1, results_csvs.size)
buildstockbatch_path = results_csvs[0]
buildstockbatch = CSV.read(buildstockbatch_path, headers: true)
# Read BuildStockBatch results
results_csvs = Dir[File.join(@buildstock_directory, "project_national/sdr_upgrades_tmy3/results_csvs/results_up*.csv")]
assert_equal(17, results_csvs.size)
buildstockbatch_path = results_csvs[1] # Only test at one upgrade
buildstockbatch = CSV.read(buildstockbatch_path, headers: true)

run_analysis_path = File.join(@buildstock_directory, "run_analysis/project_#{project}/results-PackageUpgrade.csv")
run_analysis = CSV.read(run_analysis_path, headers: true)
# Identify empty columns and drop them
empty_columns = buildstockbatch.headers.select do |header|
buildstockbatch[header].all? { |cell| cell.nil? || cell.empty? }
end

buildstockbatch_extras = buildstockbatch.headers - run_analysis.headers
buildstockbatch_extras -= ['apply_upgrade.reference_scenario']
buildstockbatch_extras -= ['simulation_output_report.applicable'] # buildstockbatch contains simulation_output_report.applicable (old workflow)
# Read run_analysis results
run_analysis_path = File.join(@buildstock_directory, "sdr_upgrades_tmy3/results-ENERGYSTARheatpumpwithelecbackup.csv")
run_analysis = CSV.read(run_analysis_path, headers: true)

puts "#{project}_upgrades, buildstockbatch - run_analysis: #{buildstockbatch_extras}" if !buildstockbatch_extras.empty?
# Test if BuildStockBatch has extra columns that are not empty
buildstockbatch_extras = buildstockbatch.headers - run_analysis.headers
buildstockbatch_extras -= ['simulation_output_report.applicable'] # buildstockbatch contains simulation_output_report.applicable (old workflow)
empty_columns.each do |col| # Remove empty columns from the diff. BuildStockBatch sometimes has empty blank columns
buildstockbatch_extras -= [col]
end

run_analysis_extras = run_analysis.headers - buildstockbatch.headers
puts "#{project}_upgrades, run_analysis - buildstockbatch: #{run_analysis_extras}" if !run_analysis_extras.empty?
puts "sdr_upgrades_tmy3, buildstockbatch - run_analysis: #{buildstockbatch_extras}" if !buildstockbatch_extras.empty?

assert_equal(0, buildstockbatch_extras.size)
assert_equal(0, run_analysis_extras.size)
end
# Test if run_analysis has extra columns
run_analysis_extras = run_analysis.headers - buildstockbatch.headers
puts "sdr_upgrades_tmy3, run_analysis - buildstockbatch: #{run_analysis_extras}" if !run_analysis_extras.empty?

assert_equal(0, buildstockbatch_extras.size)
assert_equal(0, run_analysis_extras.size)
end

def test_baseline_results
Expand Down

0 comments on commit 0d7fb07

Please sign in to comment.