Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosejoycrocker committed Oct 28, 2024
1 parent 2feceff commit d72ce02
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
22 changes: 11 additions & 11 deletions ext/AvizExt/viz/spatial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function create_map!(
end

reset_limits!(current_axis())
if typeof(f)==GridLayout
if typeof(f) == GridLayout
trim!(f)
end
resize_to_layout!(current_figure())
Expand Down Expand Up @@ -262,24 +262,24 @@ function ADRIA.viz.map(
rs::Union{Domain,ResultSet},
M::YAXArray,
scores::Vector{Float64};
criteria::Vector{Symbol} = Array(M.criteria),
criteria::Vector{Symbol}=Array(M.criteria),
opts::OPT_TYPE=DEFAULT_OPT_TYPE(),
fig_opts::OPT_TYPE=set_figure_defaults(DEFAULT_OPT_TYPE()),
axis_opts::OPT_TYPE=set_axis_defaults(DEFAULT_OPT_TYPE())
)
f = Figure(; fig_opts...)
g = f[1, 1] = GridLayout()
ADRIA.viz.map!(
g, rs, M, scores; criteria = criteria, opts = opts, axis_opts = axis_opts
g, rs, M, scores; criteria=criteria, opts=opts, axis_opts=axis_opts
)
return f
end
function ADRIA.viz.map!(
g::Union{GridLayout, GridPosition},
g::Union{GridLayout,GridPosition},
rs::Union{Domain,ResultSet},
M::YAXArray,
scores::Vector{Float64};
criteria::Vector{Symbol} = Array(M.criteria),
criteria::Vector{Symbol}=Array(M.criteria),
opts::OPT_TYPE=DEFAULT_OPT_TYPE(),
axis_opts::OPT_TYPE=set_axis_defaults(DEFAULT_OPT_TYPE())
)
Expand All @@ -294,9 +294,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 @@ -309,8 +309,8 @@ function ADRIA.viz.map!(
g[row, col],
rs,
vec(scores);
opts = opts,
axis_opts = axis_opts,
opts=opts,
axis_opts=axis_opts
)
break
end
Expand All @@ -319,8 +319,8 @@ function ADRIA.viz.map!(
g[row, col],
rs,
vec(M[criteria=At(criteria[step])]);
opts = opts,
axis_opts = axis_opts
opts=opts,
axis_opts=axis_opts
)

step += 1
Expand Down
45 changes: 23 additions & 22 deletions src/decision/Criteria/DecisionPreferences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,29 @@ Note: Ignores constant criteria values.
# Returns
Returns raw aggreagted score for a set of locations
"""
function get_criteria_aggregate(dp::T, dm::YAXArray, method::Union{Function,DataType}
)where {T<:DecisionPreference}
# Identify valid, non-constant, columns for use in MCDA
is_const = Bool[length(x) == 1 for x in unique.(eachcol(dm.data))]

# YAXArrays will throw error for all false boolean masks
if all(is_const)
throw(DomainError(is_const, "No Ranking Possible, all criteria are constant"))
end

# Recreate preferences, removing criteria that are constant for this scenario
_dp = filter_criteria(dp, is_const)

# Assess decision matrix only using valid (non-constant) criteria
res = solve(_dp, dm[criteria=.!is_const], method)

if all(isnan.(res.scores))
# This may happen if there are constants in the decision matrix
# or if the method fails for some reason...
throw(DomainError(res.scores, "No ranking possible"))
end
return (scores=res.scores, bestIndex=res.bestIndex)
function get_criteria_aggregate(
dp::T, dm::YAXArray, method::Union{Function,DataType}
) where {T<:DecisionPreference}
# Identify valid, non-constant, columns for use in MCDA
is_const = Bool[length(x) == 1 for x in unique.(eachcol(dm.data))]

# YAXArrays will throw error for all false boolean masks
if all(is_const)
throw(DomainError(is_const, "No Ranking Possible, all criteria are constant"))
end

# Recreate preferences, removing criteria that are constant for this scenario
_dp = filter_criteria(dp, is_const)

# Assess decision matrix only using valid (non-constant) criteria
res = solve(_dp, dm[criteria=.!is_const], method)

if all(isnan.(res.scores))
# This may happen if there are constants in the decision matrix
# or if the method fails for some reason...
throw(DomainError(res.scores, "No ranking possible"))
end
return (scores=res.scores, bestIndex=res.bestIndex)
end

"""
Expand Down

0 comments on commit d72ce02

Please sign in to comment.