diff --git a/docs/make.jl b/docs/make.jl index c9619c4..27b702b 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,6 +1,6 @@ using Documenter, PowerGraphics -makedocs( +makedocs(; modules = [PowerGraphics], format = Documenter.HTML(), sitename = "PowerGraphics.jl", @@ -12,7 +12,7 @@ makedocs( ], ) -Documenter.deploydocs( +Documenter.deploydocs(; repo = "github.com/NREL-Sienna/PowerGraphics.jl.git", target = "build", branch = "gh-pages", diff --git a/src/call_plots.jl b/src/call_plots.jl index 1504df6..cb0f440 100644 --- a/src/call_plots.jl +++ b/src/call_plots.jl @@ -176,7 +176,6 @@ plot = plot_dataframe(df, time_range) - `nofill::Bool` : force empty area fill - `stair::Bool`: Make a stair plot instead of a stack plot """ - function plot_dataframe(df::DataFrames.DataFrame; kwargs...) return plot_dataframe!(_empty_plot(), PA.no_datetime(df), df.DateTime; kwargs...) end @@ -213,7 +212,6 @@ If only the dataframe is provided, it must have a column of `DateTime` values. - `nofill::Bool` : force empty area fill - `stair::Bool`: Make a stair plot instead of a stack plot """ - function plot_dataframe!(p, df::DataFrames.DataFrame; kwargs...) return plot_dataframe!(p, PA.no_datetime(df), df.DateTime; kwargs...) end @@ -404,7 +402,6 @@ plot = plot_fuel(res) - `stair::Bool`: Make a stair plot instead of a stack plot - `filter_func::Function = PowerSystems.get_available` : filter components included in plot """ - function plot_fuel(result::IS.Results; kwargs...) return plot_fuel!(_empty_plot(), result; kwargs...) end diff --git a/src/definitions.jl b/src/definitions.jl index ef5c58c..adf2b61 100644 --- a/src/definitions.jl +++ b/src/definitions.jl @@ -45,7 +45,7 @@ function load_palette(file) for (k, v) in palette_config push!(palette_colors, PaletteColor(k, v["RGB"], v["order"])) end - sort!(palette_colors, by = x -> x.order) + sort!(palette_colors; by = x -> x.order) return palette_colors end @@ -117,7 +117,7 @@ function match_fuel_colors(data::DataFrames.DataFrame, backend; palette = PALETT color_range = get_palette_fuel(palette) end color_fuel = - DataFrames.DataFrame(fuels = get_palette_category(palette), colors = color_range) + DataFrames.DataFrame(; fuels = get_palette_category(palette), colors = color_range) names = DataFrames.names(data) default = [(color_fuel[findall(in(["$(names[1])"]), color_fuel.fuels), :][:, :colors])[1]] diff --git a/src/make_report.jl b/src/make_report.jl index 4651770..4534d50 100644 --- a/src/make_report.jl +++ b/src/make_report.jl @@ -33,7 +33,7 @@ function report(res::IS.Results, out_path::String, design_template::String; kwar throw(ArgumentError("The provided template file is invalid")) args = Dict("results" => res, "backend" => backend) Weave.weave( - design_template, + design_template; out_path = out_path, latex_cmd = ["xelatex"], doctype = doctype, diff --git a/src/plot_recipes.jl b/src/plot_recipes.jl index 86e4919..ef24c17 100644 --- a/src/plot_recipes.jl +++ b/src/plot_recipes.jl @@ -47,7 +47,7 @@ function _dataframe_plots_internal( data = Matrix(PA.no_datetime(variable)) labels = DataFrames.names(PA.no_datetime(variable)) if stack - plot_data = cumsum(data, dims = 2) + plot_data = cumsum(data; dims = 2) if !nofill plot_kwargs[:fillrange] = hcat(zeros(length(time_range)), plot_data) end @@ -75,7 +75,7 @@ function _dataframe_plots_internal( plot_kwargs[:grid] = false if bar - plot_data = sum(plot_data, dims = 1) ./ interval + plot_data = sum(plot_data; dims = 1) ./ interval if stack x = nothing plot_data = plot_data[end:-1:1, end:-1:1] diff --git a/src/plotly_recipes.jl b/src/plotly_recipes.jl index 54dff1b..3ad6cc3 100644 --- a/src/plotly_recipes.jl +++ b/src/plotly_recipes.jl @@ -45,7 +45,7 @@ function _dataframe_plots_internal( plot_kwargs = Dict() if bar - plot_data = sum(plot_data, dims = 1) ./ interval + plot_data = sum(plot_data; dims = 1) ./ interval showtxicklabels = false if nofill plot_kwargs[:type] = "scatter" diff --git a/test/test_data/results_data.jl b/test/test_data/results_data.jl index 7f3ccd3..9621675 100644 --- a/test/test_data/results_data.jl +++ b/test/test_data/results_data.jl @@ -31,7 +31,7 @@ function add_re!(sys) for g in get_components(HydroEnergyReservoir, sys) tpc = get_operation_cost(g) - smc = StorageManagementCost( + smc = StorageManagementCost(; variable = get_variable(tpc), fixed = get_fixed(tpc), start_up = 0.0, @@ -68,12 +68,12 @@ function run_test_sim(result_dir::String) if ispath(sim_path) @info "Reading UC system from" sim_path c_sys5_hy_uc = System( - joinpath(sim_path, "..", "c_sys5_hy_uc.json"), + joinpath(sim_path, "..", "c_sys5_hy_uc.json"); time_series_read_only = true, ) @info "Reading ED system from" sim_path c_sys5_hy_ed = System( - joinpath(sim_path, "..", "c_sys5_hy_ed.json"), + joinpath(sim_path, "..", "c_sys5_hy_ed.json"); time_series_read_only = true, ) results_folders = filter!(x -> occursin("results_sim", x), readdir(result_dir)) @@ -89,8 +89,8 @@ function run_test_sim(result_dir::String) @info "Adding extra RE" add_re!(c_sys5_hy_uc) add_re!(c_sys5_hy_ed) - to_json(c_sys5_hy_uc, joinpath(sim_path, "..", "c_sys5_hy_uc.json"), force = true) - to_json(c_sys5_hy_ed, joinpath(sim_path, "..", "c_sys5_hy_ed.json"), force = true) + to_json(c_sys5_hy_uc, joinpath(sim_path, "..", "c_sys5_hy_uc.json"); force = true) + to_json(c_sys5_hy_ed, joinpath(sim_path, "..", "c_sys5_hy_ed.json"); force = true) mkpath(result_dir) GLPK_optimizer = @@ -105,7 +105,7 @@ function run_test_sim(result_dir::String) ) set_device_model!(template_hydro_st_uc, GenericBattery, StorageDispatchWithReserves) - template_hydro_st_ed = template_economic_dispatch( + template_hydro_st_ed = template_economic_dispatch(; network = CopperPlatePowerModel, use_slacks = true, duals = [CopperPlateBalanceConstraint], @@ -118,18 +118,18 @@ function run_test_sim(result_dir::String) ) set_device_model!(template_hydro_st_ed, GenericBattery, StorageDispatchWithReserves) template_hydro_st_ed.services = Dict() #remove ed services - models = SimulationModels( + models = SimulationModels(; decision_models = [ DecisionModel( template_hydro_st_uc, - c_sys5_hy_uc, + c_sys5_hy_uc; optimizer = GLPK_optimizer, name = "UC", system_to_file = false, ), DecisionModel( template_hydro_st_ed, - c_sys5_hy_ed, + c_sys5_hy_ed; optimizer = GLPK_optimizer, name = "ED", system_to_file = false, @@ -137,11 +137,11 @@ function run_test_sim(result_dir::String) ], ) - sequence = SimulationSequence( + sequence = SimulationSequence(; models = models, feedforwards = feedforward = Dict( "ED" => [ - SemiContinuousFeedforward( + SemiContinuousFeedforward(; component_type = ThermalStandard, source = OnVariable, affected_values = [ActivePowerVariable], @@ -150,7 +150,7 @@ function run_test_sim(result_dir::String) ), ini_cond_chronology = InterProblemChronology(), ) - sim = Simulation( + sim = Simulation(; name = "results_sim", steps = 2, models = models, @@ -186,11 +186,11 @@ function run_test_prob() prob = DecisionModel( template_hydro_st_uc, - c_sys5_hy_uc, + c_sys5_hy_uc; optimizer = GLPK_optimizer, horizon = 12, ) - build!(prob, output_dir = mktempdir()) + build!(prob; output_dir = mktempdir()) solve!(prob) res = ProblemResults(prob) return res diff --git a/test/test_plot_creation.jl b/test/test_plot_creation.jl index f3e1174..9659b24 100644 --- a/test/test_plot_creation.jl +++ b/test/test_plot_creation.jl @@ -36,7 +36,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") ) plot_dataframe( gen_uc.data[:ActivePowerVariable__ThermalStandard], - gen_uc.time, + gen_uc.time; set_display = set_display, title = "df_stack", save = out_path, @@ -44,7 +44,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") ) plot_dataframe( gen_uc.data[:ActivePowerVariable__ThermalStandard], - gen_uc.time, + gen_uc.time; set_display = set_display, title = "df_stair", save = out_path, @@ -52,7 +52,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") ) plot_dataframe( gen_uc.data[:ActivePowerVariable__ThermalStandard], - gen_uc.time, + gen_uc.time; set_display = set_display, title = "df_bar", save = out_path, @@ -60,7 +60,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") ) plot_dataframe( gen_uc.data[:ActivePowerVariable__ThermalStandard], - gen_uc.time, + gen_uc.time; set_display = set_display, title = "df_bar_stack", save = out_path, @@ -70,12 +70,12 @@ function test_plots(file_path::String; backend_pkg::String = "gr") plot_dataframe!( plot_dataframe( gen_uc.data[:ActivePowerVariable__ThermalStandard], - gen_uc.time, + gen_uc.time; set_display = set_display, stack = true, ), no_datetime(load_uc.data[:Load]) .* -1, - gen_uc.time, + gen_uc.time; set_display = set_display, title = "df_gen_load", save = out_path, @@ -96,7 +96,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") @test isempty(setdiff(list, expected_files)) @info("removing test files") - cleanup && rm(out_path, recursive = true) + cleanup && rm(out_path; recursive = true) end @testset "test $backend_pkg powerdata plot production" begin @@ -104,7 +104,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") !isdir(out_path) && mkdir(out_path) PG.plot_powerdata( - gen_uc, + gen_uc; set_display = set_display, title = "pg_data", save = out_path, @@ -112,7 +112,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") stack = false, ) PG.plot_powerdata( - gen_uc, + gen_uc; set_display = set_display, title = "pg_data_stack", save = out_path, @@ -120,7 +120,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") stack = true, ) PG.plot_powerdata( - gen_uc, + gen_uc; set_display = set_display, title = "pg_data_bar", save = out_path, @@ -128,7 +128,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") stack = false, ) PG.plot_powerdata( - gen_uc, + gen_uc; set_display = set_display, title = "pg_data_bar_stack", save = out_path, @@ -145,14 +145,14 @@ function test_plots(file_path::String; backend_pkg::String = "gr") @test isempty(setdiff(list, expected_files)) @info("removing test files") - cleanup && rm(out_path, recursive = true) + cleanup && rm(out_path; recursive = true) end @testset "test $backend_pkg demand plot production" begin out_path = joinpath(file_path, backend_pkg * "_demand_plots") !isdir(out_path) && mkdir(out_path) PG.plot_demand( - results_uc, + results_uc; set_display = set_display, title = "demand", save = out_path, @@ -162,7 +162,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") filter_func = x -> get_name(get_bus(x)) == "bus2", ) PG.plot_demand( - results_uc, + results_uc; set_display = set_display, title = "demand_stack", save = out_path, @@ -171,7 +171,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") nofill = false, ) PG.plot_demand( - results_uc, + results_uc; set_display = set_display, title = "demand_bar", save = out_path, @@ -180,7 +180,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") nofill = false, ) PG.plot_demand( - results_uc, + results_uc; set_display = set_display, title = "demand_bar_stack", save = out_path, @@ -189,7 +189,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") nofill = false, ) PG.plot_demand( - results_uc, + results_uc; set_display = set_display, title = "demand_nofill", save = out_path, @@ -198,7 +198,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") nofill = true, ) PG.plot_demand( - results_uc, + results_uc; set_display = set_display, title = "demand_nofill_stack", save = out_path, @@ -207,7 +207,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") nofill = true, ) PG.plot_demand( - results_uc, + results_uc; set_display = set_display, title = "demand_nofill_bar", save = out_path, @@ -216,7 +216,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") nofill = true, ) PG.plot_demand( - results_uc, + results_uc; set_display = set_display, title = "demand_nofill_bar_stack", save = out_path, @@ -226,7 +226,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") ) p = PG.plot_demand( - results_uc.system, + results_uc.system; set_display = set_display, title = "sysdemand", save = out_path, @@ -236,7 +236,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") @test plot_length == 1 p = PG.plot_demand( - results_uc.system, + results_uc.system; set_display = set_display, title = "sysdemand_bus", save = out_path, @@ -264,7 +264,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") @test isempty(setdiff(list, expected_files)) @info("removing test files") - cleanup && rm(out_path, recursive = true) + cleanup && rm(out_path; recursive = true) end @testset "test $backend_pkg fuel plot production" begin @@ -272,7 +272,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") !isdir(out_path) && mkdir(out_path) PG.plot_fuel( - results_uc, + results_uc; set_display = set_display, title = "fuel", save = out_path, @@ -281,7 +281,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") filter_func = x -> get_name(get_area(get_bus(x))) == "1", ) PG.plot_fuel( - results_uc, + results_uc; set_display = set_display, title = "fuel_stack", save = out_path, @@ -289,7 +289,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") stack = true, ) PG.plot_fuel( - results_uc, + results_uc; set_display = set_display, title = "fuel_bar", save = out_path, @@ -297,7 +297,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") stack = false, ) PG.plot_fuel( - results_uc, + results_uc; set_display = set_display, title = "fuel_bar_stack", save = out_path, @@ -314,7 +314,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") @test isempty(setdiff(list, expected_files)) @info("removing test files") - cleanup && rm(out_path, recursive = true) + cleanup && rm(out_path; recursive = true) end @testset "test alternate mapping yamls" begin @@ -325,7 +325,7 @@ function test_plots(file_path::String; backend_pkg::String = "gr") palette = PG.load_palette(joinpath(TEST_DIR, "test_yamls/color-palette.yaml")) PG.plot_fuel( - results_uc, + results_uc; set_display = set_display, title = "fuel", save = out_path, @@ -342,12 +342,12 @@ function test_plots(file_path::String; backend_pkg::String = "gr") @test isempty(setdiff(list, expected_files)) @info "removing alternate test fuel outputs" - cleanup && rm(out_path, recursive = true) + cleanup && rm(out_path; recursive = true) end @testset "test html saving" begin plot_fuel( - results_ed, + results_ed; set_display = false, save = TEST_RESULT_DIR, title = "fuel_html_output", @@ -357,9 +357,9 @@ function test_plots(file_path::String; backend_pkg::String = "gr") end end try - test_plots(file_path, backend_pkg = "gr") + test_plots(file_path; backend_pkg = "gr") @info("done with GR, starting plotlyjs") - test_plots(file_path, backend_pkg = "plotlyjs") + test_plots(file_path; backend_pkg = "plotlyjs") finally nothing end diff --git a/test/test_reports.jl b/test/test_reports.jl index 0e5b3e7..d8461e7 100644 --- a/test/test_reports.jl +++ b/test/test_reports.jl @@ -26,13 +26,13 @@ function test_reports(file_path::String; backend_pkg::String = "gr") @test isfile(report_out_path) @info("removing test files") - cleanup && rm(out_path, recursive = true) + cleanup && rm(out_path; recursive = true) end end try - test_reports(file_path, backend_pkg = "gr") - test_reports(file_path, backend_pkg = "plotlyjs") + test_reports(file_path; backend_pkg = "gr") + test_reports(file_path; backend_pkg = "plotlyjs") finally nothing end