Skip to content

Commit

Permalink
Merge pull request #112 from NREL-Sienna/jd-lara-patch-1
Browse files Browse the repository at this point in the history
Update Project.toml
  • Loading branch information
jd-lara authored Feb 8, 2024
2 parents 77a5a51 + 1dfae8a commit 353ea1d
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 116 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: format-check
name: Format Check

on:
push:
Expand All @@ -13,19 +13,23 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.6.0]
julia-version: [1]
julia-arch: [x86]
os: [ubuntu-latest]
steps:
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Install JuliaFormatter and format
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version = "0.14.1"))'
julia -e 'using JuliaFormatter; include(".github/workflows/formatter/formatter_code.jl")'
julia -e 'include("scripts/formatter/formatter_code.jl")'
- uses: reviewdog/action-suggester@v1
if: github.event_name == 'pull_request'
with:
tool_name: JuliaFormatter
fail_on_error: true
- name: Format check
run: |
julia -e '
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/formatter/formatter_code.jl

This file was deleted.

11 changes: 0 additions & 11 deletions .github/workflows/formatter_code.jl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
julia-version: ['1', 'nightly']
julia-arch: [x64]
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
matrix:
julia-version: ['1']
julia-arch: [x64]
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PowerGraphics"
uuid = "5f7eddb3-86b1-49e8-a95a-ddc0f45eea41"
authors = ["Clayton Barrows", "Lily Hanig", "Jose Daniel Lara", "Sourabh Dalvi", "Dheepak Krishnamurthy"]
version = "0.16.0"
version = "0.17.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
Expand All @@ -26,7 +26,7 @@ DataFrames = "1"
DataStructures = "0.18"
InfrastructureSystems = "1"
Plots = "1"
PowerAnalytics = "^0.5"
PowerAnalytics = "^0.6"
PowerSystems = "3"
Reexport = "1"
Requires = "1"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PowerGraphics.jl is a Julia package for plotting results from [PowerSimulations.

```julia
julia> ]
(v1.6) pkg> add PowerGraphics
(v1.10) pkg> add PowerGraphics
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Documenter, PowerGraphics

makedocs(
makedocs(;
modules = [PowerGraphics],
format = Documenter.HTML(),
sitename = "PowerGraphics.jl",
Expand All @@ -12,7 +12,7 @@ makedocs(
],
)

Documenter.deploydocs(
Documenter.deploydocs(;
repo = "github.com/NREL-Sienna/PowerGraphics.jl.git",
target = "build",
branch = "gh-pages",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[compat]
JuliaFormatter = "v0.18"
julia = "^1.2"
JuliaFormatter = "1.0"
julia = "^1.7"
28 changes: 28 additions & 0 deletions scripts/formatter/formatter_code.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Pkg
Pkg.activate(@__DIR__)
Pkg.instantiate()
Pkg.update()

using JuliaFormatter

main_paths = ["."]
for main_path in main_paths
for (root, dir, files) in walkdir(main_path)
for f in files
@show file_path = abspath(root, f)
!occursin(".jl", f) && continue
format(file_path;
whitespace_ops_in_indices = true,
remove_extra_newlines = true,
verbose = true,
always_for_in = true,
whitespace_typedefs = true,
conditional_to_if = true,
join_lines_based_on_source = true,
separate_kwargs_with_semicolon = true,

# always_use_return = true. # Disabled since it throws a lot of false positives
)
end
end
end
3 changes: 0 additions & 3 deletions src/call_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]]
Expand Down
2 changes: 1 addition & 1 deletion src/make_report.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/plot_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -86,7 +86,7 @@ function _dataframe_plots_internal(
x = labels
plot_data = permutedims(plot_data)
plot_kwargs[:lab] = hcat(string.(labels)...)
plot_kwargs[:seriescolor] = permutedims(seriescolor)
plot_kwargs[:seriescolor] = seriescolor[:, length(labels):-1:1]
plot_kwargs[:legend] = false
end
plot_func = nofill ? Plots.hline! : Plots.bar!
Expand Down
2 changes: 1 addition & 1 deletion src/plotly_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
38 changes: 19 additions & 19 deletions test/test_data/results_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -68,17 +68,17 @@ 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,
)
executions = tryparse.(Int, readdir(sim_path))
sim = joinpath(sim_path, string(maximum(executions)))
@info "Reading results from last execution" sim
results_folders = filter!(x -> occursin("results_sim", x), readdir(result_dir))
sim = joinpath(result_dir, last(results_folders))
@info "Reading results from last execution" last(results_folders)
else
@info "Building UC system from"
c_sys5_hy_uc = PSB.build_system(PSB.PSISystems, "5_bus_hydro_uc_sys")
Expand All @@ -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 =
Expand All @@ -103,9 +103,9 @@ function run_test_sim(result_dir::String)
HydroEnergyReservoir,
HydroDispatchReservoirStorage,
)
set_device_model!(template_hydro_st_uc, GenericBattery, BookKeeping)
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],
Expand All @@ -116,32 +116,32 @@ function run_test_sim(result_dir::String)
HydroEnergyReservoir,
HydroDispatchReservoirStorage,
)
set_device_model!(template_hydro_st_ed, GenericBattery, BookKeeping)
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,
),
],
)

sequence = SimulationSequence(
sequence = SimulationSequence(;
models = models,
feedforwards = feedforward = Dict(
"ED" => [
SemiContinuousFeedforward(
SemiContinuousFeedforward(;
component_type = ThermalStandard,
source = OnVariable,
affected_values = [ActivePowerVariable],
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Loading

2 comments on commit 353ea1d

@jd-lara
Copy link
Member Author

@jd-lara jd-lara commented on 353ea1d Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/100518

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.17.0 -m "<description of version>" 353ea1d4896d7b8596276f8a79256b5f5c3c644b
git push origin v0.17.0

Please sign in to comment.