Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ InfrastructureSystems = "3"
JSON3 = "1"
LazyArtifacts = "1"
PowerSystems = "^5.0.1"
PrettyTables = "2"
PrettyTables = "2.4, 3.1"
Random = "1"
SHA = "0.7"
TimeSeries = "^0.24, ^0.25"
Expand Down
10 changes: 10 additions & 0 deletions src/PowerSystemCaseBuilder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,17 @@ include("system_descriptor.jl")
include("system_catalog.jl")

include("utils/download.jl")

include("utils/print.jl")
@static if pkgversion(PrettyTables).major == 2
# When PrettyTables v2 is more widely adopted in the ecosystem, we can remove this file.
# In this case, we should also update the compat bounds in Project.toml to list only
# PrettyTables v3.
include("utils/print_pt_v2.jl")
else
include("utils/print_pt_v3.jl")
end

include("utils/utils.jl")
include("utils/spi_library_utils.jl")

Expand Down
13 changes: 0 additions & 13 deletions src/utils/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ function Base.show(io::IO, sys::SystemCatalog)
show(df; allrows = true)
end

function show_systems(sys::SystemCatalog, category::Type{<:SystemCategory}; kwargs...)
descriptors = get_system_descriptors(category, sys)
sort!(descriptors; by = x -> x.name)
header = ["Name", "Descriptor"]
data = Array{Any, 2}(undef, length(descriptors), length(header))
for (i, d) in enumerate(descriptors)
data[i, 1] = get_name(d)
data[i, 2] = get_description(d)
end

PrettyTables.pretty_table(stdout, data; header = header, alignment = :l, kwargs...)
end

"""
Prints the names of the [`SystemCategory`](@ref)s available in the
`PowerSystemCaseBuilder.jl` catalog
Expand Down
12 changes: 12 additions & 0 deletions src/utils/print_pt_v2.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function show_systems(sys::SystemCatalog, category::Type{<:SystemCategory}; kwargs...)
descriptors = get_system_descriptors(category, sys)
sort!(descriptors; by = x -> x.name)
header = ["Name", "Descriptor"]
data = Array{Any, 2}(undef, length(descriptors), length(header))
for (i, d) in enumerate(descriptors)
data[i, 1] = get_name(d)
data[i, 2] = get_description(d)
end

PrettyTables.pretty_table(stdout, data; header = header, alignment = :l, kwargs...)
end
18 changes: 18 additions & 0 deletions src/utils/print_pt_v3.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function show_systems(sys::SystemCatalog, category::Type{<:SystemCategory}; kwargs...)
descriptors = get_system_descriptors(category, sys)
sort!(descriptors; by = x -> x.name)
column_labels = ["Name", "Descriptor"]
data = Array{Any, 2}(undef, length(descriptors), length(column_labels))
for (i, d) in enumerate(descriptors)
data[i, 1] = get_name(d)
data[i, 2] = get_description(d)
end

PrettyTables.pretty_table(
stdout,
data;
column_labels = column_labels,
alignment = :l,
kwargs...,
)
end
Loading