Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosejoycrocker committed Jan 24, 2024
1 parent 05f92ea commit ef520b8
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 305 deletions.
46 changes: 23 additions & 23 deletions ext/AvizExt/viz/location_selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function ADRIA.viz.ranks_to_frequencies!(
rs::ResultSet,
frequencies::NamedDimsArray,
rank_ids::Vector{Int64};
opts::Dict = Dict(),
axis_opts::Dict = Dict(),
opts::Dict=Dict(),
axis_opts::Dict=Dict(),
)
sym_rank_ids = Symbol.(rank_ids)
rank_groups = Dict(rank_grp => rank_grp .== sym_rank_ids for rank_grp in sym_rank_ids)
Expand All @@ -58,12 +58,12 @@ function ADRIA.viz.ranks_to_frequencies!(
ADRIA.viz.map!(
g,
rs,
frequencies[ranks = rank_ids[1]];
opts = opts,
axis_opts = axis_opts
frequencies[ranks=rank_ids[1]];
opts=opts,
axis_opts=axis_opts,
)
legend_els[1] = PolyElement(;
color = all_colormaps[Symbol(rank_ids[1])][2], strokecolor = :grey, strokewidth = 1
color=all_colormaps[Symbol(rank_ids[1])][2], strokecolor=:grey, strokewidth=1
)
legend_labels[1] = string("Rank ", string(rank_ids[1]))
ax = content(g[1, 1]) # get GeoAxis
Expand All @@ -72,28 +72,28 @@ function ADRIA.viz.ranks_to_frequencies!(
poly!(
ax,
geodata;
color = collect(frequencies[ranks = rr]),
colormap = all_colormaps[Symbol(rr)],
strokecolor = :grey,
strokewidth = 0.5,
linestyle = :solid,
overdraw = true,
color=collect(frequencies[ranks=rr]),
colormap=all_colormaps[Symbol(rr)],
strokecolor=:grey,
strokewidth=0.5,
linestyle=:solid,
overdraw=true,
)
legend_els[rr] = PolyElement(;
color = all_colormaps[Symbol(rr)][2], strokecolor = :grey, strokewidth = 1
color=all_colormaps[Symbol(rr)][2], strokecolor=:grey, strokewidth=1
)
legend_labels[rr] = string("Rank ", string(rr))
end
Legend(g[1, 2], legend_els, legend_labels; patchsize = (35, 35), rowgap = 10)
Legend(g[1, 2], legend_els, legend_labels; patchsize=(35, 35), rowgap=10)
return g
end
function ADRIA.viz.ranks_to_frequencies!(
g::Union{GridLayout, GridPosition},
rs::ResultSet,
frequencies::NamedDimsArray,
rank_id::Int64;
opts::Dict = Dict(),
axis_opts::Dict = Dict())
opts::Dict=Dict(),
axis_opts::Dict=Dict())
opts[:colorbar_label] = get(opts, :colorbar_label, "Selection frequency")
opts[:color_map] = get(
opts,
Expand All @@ -104,26 +104,26 @@ function ADRIA.viz.ranks_to_frequencies!(
return ADRIA.viz.map!(
g,
rs,
AxisKeys.keyless(NamedDims.unname(frequencies[ranks = rank_id]));
opts = opts,
axis_opts = axis_opts,
AxisKeys.keyless(NamedDims.unname(frequencies[ranks=rank_id]));
opts=opts,
axis_opts=axis_opts,
)
end
function ADRIA.viz.ranks_to_frequencies(
rs::ResultSet,
frequencies::NamedDimsArray,
rank_ids::Union{Int64, Vector{Int64}};
opts::Dict = Dict(),
fig_opts::Dict = Dict(), axis_opts::Dict = Dict())
opts::Dict=Dict(),
fig_opts::Dict=Dict(), axis_opts::Dict=Dict())
f = Figure(; fig_opts...)
g = f[1, 1] = GridLayout()
ADRIA.viz.ranks_to_frequencies!(
g,
rs,
frequencies,
rank_ids;
opts = opts,
axis_opts = axis_opts
opts=opts,
axis_opts=axis_opts,
)

return f
Expand Down
102 changes: 51 additions & 51 deletions ext/AvizExt/viz/spatial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ function create_map!(
data::Observable,
highlight::Union{Vector, Tuple, Nothing},
centroids::Vector,
show_colorbar::Bool = true,
colorbar_label::String = "",
colorbar_limits::Tuple{Float64, Float64} = (0.0, maximum(data)),
color_map::Union{Symbol, Vector{Symbol}, RGBA{Float32}, Vector{RGBA{Float32}}} = :grayC,
legend_params::Union{Tuple, Nothing} = nothing,
axis_opts::Dict = Dict(),
show_colorbar::Bool=true,
colorbar_label::String="",
colorbar_limits::Tuple{Float64, Float64}=(0.0, maximum(data)),
color_map::Union{Symbol, Vector{Symbol}, RGBA{Float32}, Vector{RGBA{Float32}}}=:grayC,
legend_params::Union{Tuple, Nothing}=nothing,
axis_opts::Dict=Dict(),
)
axis_opts[:title] = get(axis_opts, :title, "Study Area")
axis_opts[:xlabel] = get(axis_opts, :xlabel, "Longitude")
axis_opts[:ylabel] = get(axis_opts, :ylabel, "Latitude")

spatial = GeoAxis(
f[1, 1];
dest = "+proj=latlong +datum=WGS84",
dest="+proj=latlong +datum=WGS84",
axis_opts...,
)
# lon = first.(centroids)
Expand All @@ -65,19 +65,19 @@ function create_map!(
poly!(
spatial,
geodata;
color = data,
colormap = color_map,
strokecolor = (:black, 0.05),
strokewidth = 1.0,
color=data,
colormap=color_map,
strokecolor=(:black, 0.05),
strokewidth=1.0,
)

if show_colorbar
Colorbar(
f[1, 2];
colormap = color_map,
label = colorbar_label,
height = Relative(0.65),
limits = colorbar_limits,
colormap=color_map,
label=colorbar_label,
height=Relative(0.65),
limits=colorbar_limits,
)
end

Expand All @@ -89,34 +89,34 @@ function create_map!(
poly!(
spatial,
geodata;
color = "transparent",
strokecolor = highlight,
strokewidth = 0.5,
linestyle = :solid,
overdraw = true,
color="transparent",
strokecolor=highlight,
strokewidth=0.5,
linestyle=:solid,
overdraw=true,
)
else
hl_groups = unique(highlight)

for color in hl_groups
m = findall(highlight .== [color])
subset_feat = FC(; features = geodata[m])
subset_feat = FC(; features=geodata[m])

poly!(
spatial,
subset_feat;
color = "transparent",
strokecolor = color,
strokewidth = 0.5,
linestyle = :solid,
overdraw = true,
color="transparent",
strokecolor=color,
strokewidth=0.5,
linestyle=:solid,
overdraw=true,
)
end
end

if !isnothing(legend_params)
# Plot Legend only if highlight colors are present
Legend(f[1, 3], legend_params...; framevisible = false)
Legend(f[1, 3], legend_params...; framevisible=false)
end
end

Expand Down Expand Up @@ -162,9 +162,9 @@ GridPosition
function ADRIA.viz.map(
rs::Union{Domain, ResultSet},
y::NamedDimsArray;
opts::Dict = Dict(),
fig_opts::Dict = Dict(),
axis_opts::Dict = Dict(),
opts::Dict=Dict(),
fig_opts::Dict=Dict(),
axis_opts::Dict=Dict(),
)
f = Figure(; fig_opts...)
g = f[1, 1] = GridLayout()
Expand All @@ -175,9 +175,9 @@ function ADRIA.viz.map(
end
function ADRIA.viz.map(
rs::Union{Domain, ResultSet};
opts::Dict{Symbol, <:Any} = Dict{Symbol, Any}(),
fig_opts::Dict{Symbol, <:Any} = Dict{Symbol, Any}(),
axis_opts::Dict{Symbol, <:Any} = Dict{Symbol, Any}(),
opts::Dict{Symbol, <:Any}=Dict{Symbol, Any}(),
fig_opts::Dict{Symbol, <:Any}=Dict{Symbol, Any}(),
axis_opts::Dict{Symbol, <:Any}=Dict{Symbol, Any}(),
)
f = Figure(; fig_opts...)
g = f[1, 1] = GridLayout()
Expand All @@ -198,8 +198,8 @@ function ADRIA.viz.map!(
g::Union{GridLayout, GridPosition},
rs::Union{Domain, ResultSet},
y::AbstractVector{<:Real};
opts::Dict = Dict(),
axis_opts::Dict = Dict(),
opts::Dict=Dict(),
axis_opts::Dict=Dict(),
)
geodata = get_geojson_copy(rs)
data = Observable(collect(y))
Expand Down Expand Up @@ -228,15 +228,15 @@ function ADRIA.viz.map(
rs::ResultSet,
S::NamedDimsArray,
scores::Vector{Float64};
criteria::Vector{Symbol} = S.criteria,
opts::Dict = Dict(),
axis_opts::Dict = Dict(),
fig_opts::Dict = Dict(),
criteria::Vector{Symbol}=S.criteria,
opts::Dict=Dict(),
axis_opts::Dict=Dict(),
fig_opts::Dict=Dict(),
)
f = Figure(; fig_opts...)
g = f[1, 1] = GridLayout()
ADRIA.viz.map!(
g, rs, S, scores; criteria = criteria, opts = opts, axis_opts = axis_opts
g, rs, S, scores; criteria=criteria, opts=opts, axis_opts=axis_opts
)
return f
end
Expand All @@ -245,9 +245,9 @@ function ADRIA.viz.map!(
rs::ResultSet,
S::NamedDimsArray,
scores::Vector{Float64};
criteria::Vector{Symbol} = S.criteria,
opts::Dict = Dict(),
axis_opts::Dict = Dict(),
criteria::Vector{Symbol}=S.criteria,
opts::Dict=Dict(),
axis_opts::Dict=Dict(),
)
if length(rs.site_data.site_id) != size(S, 1)
error("Only unfiltered decision matrices can be plotted.")
Expand All @@ -260,9 +260,9 @@ function ADRIA.viz.map!(
criteria_names::Vector{String} = m_spec[
dropdims(
any(
reshape(criteria, 1, length(criteria)) .== m_spec[:, "fieldname"]; dims = 2
reshape(criteria, 1, length(criteria)) .== m_spec[:, "fieldname"]; dims=2
);
dims = 2,
dims=2,
), "name"]
n_criteria::Int64 = length(criteria)
n_rows, n_cols = _calc_gridsize(n_criteria + 1)
Expand All @@ -274,8 +274,8 @@ function ADRIA.viz.map!(
g[row, col],
rs,
vec(scores);
opts = opts,
axis_opts = Dict(:title => "Aggregate criteria score"; axis_opts...),
opts=opts,
axis_opts=Dict(:title => "Aggregate criteria score"; axis_opts...),
)
break
end
Expand All @@ -284,8 +284,8 @@ function ADRIA.viz.map!(
g[row, col],
rs,
vec(S(criteria[step]));
opts = opts,
axis_opts = axis_opts_temp
opts=opts,
axis_opts=axis_opts_temp,
)

step += 1
Expand All @@ -311,9 +311,9 @@ function make_geojson_copy(ds::Union{ResultSet, Domain})::String
local geo_fn = joinpath(tmpdir, "Aviz_$(ds.name).geojson")
if !isfile(geo_fn)
try
GDF.write(geo_fn, ds.site_data; driver = "geojson")
GDF.write(geo_fn, ds.site_data; driver="geojson")
catch
GDF.write(geo_fn, ds.site_data; geom_columns = (:geom,), driver = "geojson")
GDF.write(geo_fn, ds.site_data; geom_columns=(:geom,), driver="geojson")
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/ADRIA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ if ccall(:jl_generating_output, Cint, ()) == 1
Matrix{Float64},
Matrix{Float64},
Float64,
},
}
) # time: 0.1929096
Base.precompile(
Tuple{
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ S := 1.0 - 0.9
S-1 := 0.9 - 0.8
etc
"""
function discretize_outcomes(y; S = 20)
function discretize_outcomes(y; S=20)
steps = 0.0:(1 / S):1.0

y_s_hat = col_normalize(y)
Expand All @@ -101,7 +101,7 @@ Computes confidence interval for series of data.
# Returns
Confidence interval (lower bound, median and higher bound) for each series step
"""
function series_confint(data::AbstractMatrix; agg_dim::Symbol = :scenarios)::Matrix{Float64}
function series_confint(data::AbstractMatrix; agg_dim::Symbol=:scenarios)::Matrix{Float64}
slice_dim = data isa NamedDimsArray ? NamedDims.dim(data, agg_dim) : 2
return quantile.(Slices(data, slice_dim), [0.025 0.5 0.975])
end
Expand Down
Loading

0 comments on commit ef520b8

Please sign in to comment.