mirror of
https://github.com/ANL-CEEESA/RELOG.git
synced 2025-12-05 23:38:52 -06:00
Fix crash when generating transportation reports
This commit is contained in:
@@ -181,10 +181,10 @@ function transportation_report(solution)::DataFrame
|
|||||||
round(dst_location_dict["Longitude (deg)"], digits=6),
|
round(dst_location_dict["Longitude (deg)"], digits=6),
|
||||||
dst_location_dict["Input product"],
|
dst_location_dict["Input product"],
|
||||||
year,
|
year,
|
||||||
round(src_location_dict["Distance (km)"][year], digits=2),
|
round(src_location_dict["Distance (km)"], digits=2),
|
||||||
round(src_location_dict["Amount (tonne)"][year], digits=2),
|
round(src_location_dict["Amount (tonne)"][year], digits=2),
|
||||||
round(src_location_dict["Amount (tonne)"][year] *
|
round(src_location_dict["Amount (tonne)"][year] *
|
||||||
src_location_dict["Distance (km)"][year],
|
src_location_dict["Distance (km)"],
|
||||||
digits=2),
|
digits=2),
|
||||||
round(src_location_dict["Transportation cost (\$)"][year], digits=2),
|
round(src_location_dict["Transportation cost (\$)"][year], digits=2),
|
||||||
round(src_location_dict["Transportation energy (J)"][year] / 1e9, digits=2),
|
round(src_location_dict["Transportation energy (J)"][year] / 1e9, digits=2),
|
||||||
@@ -234,10 +234,10 @@ function transportation_emissions_report(solution)::DataFrame
|
|||||||
round(dst_location_dict["Longitude (deg)"], digits=6),
|
round(dst_location_dict["Longitude (deg)"], digits=6),
|
||||||
dst_location_dict["Input product"],
|
dst_location_dict["Input product"],
|
||||||
year,
|
year,
|
||||||
round(src_location_dict["Distance (km)"][year], digits=2),
|
round(src_location_dict["Distance (km)"], digits=2),
|
||||||
round(src_location_dict["Amount (tonne)"][year], digits=2),
|
round(src_location_dict["Amount (tonne)"][year], digits=2),
|
||||||
round(src_location_dict["Amount (tonne)"][year] *
|
round(src_location_dict["Amount (tonne)"][year] *
|
||||||
src_location_dict["Distance (km)"][year],
|
src_location_dict["Distance (km)"],
|
||||||
digits=2),
|
digits=2),
|
||||||
emission_name,
|
emission_name,
|
||||||
round(emission_amount[year], digits=2),
|
round(emission_amount[year], digits=2),
|
||||||
|
|||||||
@@ -20,9 +20,21 @@ function check(func, expected_csv_filename::String)
|
|||||||
end
|
end
|
||||||
|
|
||||||
@testset "Reports" begin
|
@testset "Reports" begin
|
||||||
|
@testset "from fixture" begin
|
||||||
check(RELOG.write_plants_report, "fixtures/nimh_plants.csv")
|
check(RELOG.write_plants_report, "fixtures/nimh_plants.csv")
|
||||||
check(RELOG.write_plant_outputs_report, "fixtures/nimh_plant_outputs.csv")
|
check(RELOG.write_plant_outputs_report, "fixtures/nimh_plant_outputs.csv")
|
||||||
check(RELOG.write_plant_emissions_report, "fixtures/nimh_plant_emissions.csv")
|
check(RELOG.write_plant_emissions_report, "fixtures/nimh_plant_emissions.csv")
|
||||||
check(RELOG.write_transportation_report, "fixtures/nimh_transportation.csv")
|
check(RELOG.write_transportation_report, "fixtures/nimh_transportation.csv")
|
||||||
check(RELOG.write_transportation_emissions_report, "fixtures/nimh_transportation_emissions.csv")
|
check(RELOG.write_transportation_emissions_report, "fixtures/nimh_transportation_emissions.csv")
|
||||||
end
|
end
|
||||||
|
@testset "from solve" begin
|
||||||
|
solution = RELOG.solve("$(pwd())/../instances/s1.json")
|
||||||
|
tmp_filename = tempname()
|
||||||
|
# The following should not crash
|
||||||
|
RELOG.write_plants_report(solution, tmp_filename)
|
||||||
|
RELOG.write_plant_outputs_report(solution, tmp_filename)
|
||||||
|
RELOG.write_plant_emissions_report(solution, tmp_filename)
|
||||||
|
RELOG.write_transportation_report(solution, tmp_filename)
|
||||||
|
RELOG.write_transportation_emissions_report(solution, tmp_filename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user