From 7e26a3e99985992e26754c1ea56d6fe04c07dc79 Mon Sep 17 00:00:00 2001 From: Rose Crocker Date: Tue, 29 Oct 2024 12:53:21 +1000 Subject: [PATCH] Formatting Remove incorrect additions from rebase --- ext/AvizExt/viz/spatial.jl | 24 +++++------ src/decision/Criteria/DecisionPreferences.jl | 45 ++++++++++---------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/ext/AvizExt/viz/spatial.jl b/ext/AvizExt/viz/spatial.jl index 16f648f73..190c5bfcf 100644 --- a/ext/AvizExt/viz/spatial.jl +++ b/ext/AvizExt/viz/spatial.jl @@ -151,11 +151,9 @@ function create_map!( end end - reset_limits!(current_axis()) - if typeof(f)==GridLayout + if typeof(f) == GridLayout trim!(f) end - resize_to_layout!(current_figure()) return f end @@ -262,7 +260,7 @@ 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()) @@ -270,16 +268,16 @@ function ADRIA.viz.map( 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()) ) @@ -294,9 +292,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) @@ -309,8 +307,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 @@ -319,8 +317,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 diff --git a/src/decision/Criteria/DecisionPreferences.jl b/src/decision/Criteria/DecisionPreferences.jl index 199e60dd6..66101e519 100644 --- a/src/decision/Criteria/DecisionPreferences.jl +++ b/src/decision/Criteria/DecisionPreferences.jl @@ -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 """