Skip to content

Commit

Permalink
use eachindex for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed Jun 26, 2023
1 parent 870d41d commit 18f8862
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
15 changes: 6 additions & 9 deletions src/mcdm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ function mcdm(
elseif method isa ArasMethod
aras(df, w, fns)
elseif method isa CocosoMethod
cocoso(df, w, fns, lambda = method.lambda)
cocoso(df, w, fns, lambda=method.lambda)
elseif method isa CodasMethod
codas(df, w, fns, tau = method.tau)
codas(df, w, fns, tau=method.tau)
elseif method isa CoprasMethod
copras(df, w, fns)
elseif method isa ROVMethod
rov(df, w, fns)
elseif method isa EdasMethod
edas(df, w, fns)
elseif method isa GreyMethod
grey(df, w, fns, zeta = method.zeta)
grey(df, w, fns, zeta=method.zeta)
elseif method isa MabacMethod
mabac(df, w, fns)
elseif method isa MaircaMethod
Expand All @@ -95,9 +95,9 @@ function mcdm(
elseif method isa SawMethod
saw(df, w, fns)
elseif method isa VikorMethod
vikor(df, w, fns, v = method.v)
vikor(df, w, fns, v=method.v)
elseif method isa WaspasMethod
waspas(df, w, fns, lambda = method.lambda)
waspas(df, w, fns, lambda=method.lambda)
elseif method isa WPMMethod
wpm(df, w, fns)
elseif method isa MarcosMethod
Expand Down Expand Up @@ -145,10 +145,7 @@ julia> # mcdm(setting, GreyMethod(0.6))
```
"""
function mcdm(
setting::MCDMSetting,
method::T1 = TopsisMethod(),
)::MCDMResult where {T1<:MCDMMethod}
function mcdm(setting::MCDMSetting, method::T1=TopsisMethod())::MCDMResult where {T1<:MCDMMethod}

mcdm(setting.df, setting.weights, setting.fns, method)
end
32 changes: 16 additions & 16 deletions test/testgreymcdm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ using Test
]


for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end

Expand Down Expand Up @@ -118,7 +118,7 @@ using Test
GreyNumber(2.519094173200623),
]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -152,7 +152,7 @@ using Test
GreyNumber(0.188656204),
]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end

Expand Down Expand Up @@ -251,7 +251,7 @@ using Test
GreyNumber(1.00000),
]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -289,7 +289,7 @@ using Test
GreyNumber(0.385194),
]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end

Expand Down Expand Up @@ -323,7 +323,7 @@ using Test
GreyNumber(0.34452),
GreyNumber(0.20035),
]
for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -353,7 +353,7 @@ using Test
GreyNumber(0.1454237),
]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end

Expand Down Expand Up @@ -385,7 +385,7 @@ using Test
GreyNumber(0.6625969061),
GreyNumber(0.6611032076),
]
for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -415,7 +415,7 @@ using Test
GreyNumber(0.01926526),
]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -490,7 +490,7 @@ using Test

@test result.rankings == [1, 2, 3, 4]
@test result.bestIndex == 4
for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -522,7 +522,7 @@ using Test
GreyNumber(1.0884916686098811),
]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end

Expand Down Expand Up @@ -557,7 +557,7 @@ using Test

@test result.ranks == [4, 2, 3, 1]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -591,7 +591,7 @@ using Test
GreyNumber(0.784976),
]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -623,7 +623,7 @@ using Test
@test result.bestIndex == 3
@test result.ranking == [3, 2, 5, 1, 4]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -657,7 +657,7 @@ using Test
GreyNumber(0.788239),
]

for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down Expand Up @@ -688,7 +688,7 @@ using Test
GreyNumber(0.7873956894791),
GreyNumber(0.7674278741782),
]
for i = 1:length(knownscores)
for i = eachindex(knownscores)
@test isapprox(result.scores[i], knownscores[i], atol = tol)
end
end
Expand Down

0 comments on commit 18f8862

Please sign in to comment.