Skip to content

Commit

Permalink
summary throws error when an unknown method name is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed May 26, 2024
1 parent 61180fd commit b4c0742
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Initial attempt to reduce memory allocations in `lts()`, `lms()`, `hadi92()`, `hadi94()`, `hs93()`, `robcov()`
- Replace `@assert` macro with `throw(ErrorException())` in whole code
- `depestregression` returns `Dict` instead of a `vector` of betas like other regression methods.
- `summary()` throws `ErrorException` rather than simply prompting with `@error` macro.



# v0.11.3
Expand Down
3 changes: 1 addition & 2 deletions src/summary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ function detectOutliers(X::AbstractMatrix{Float64}, y::AbstractVector{Float64};
result = Int[]
end
else
@error "Method not found " method
result = Int[]
throw(ErrorException("Method not found: $method"))
end
outlier_matrix[:, method] = makeColorColumn(result, n)
end
Expand Down
59 changes: 38 additions & 21 deletions test/testsummary.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@testset "Summary" begin
smiley = " 😔 "
methods = [

@testset "Withour errors" begin
smiley = " 😔 "
methods = [
"hs93",
"ks89",
"smr98",
Expand All @@ -10,25 +12,40 @@
"asm20",
"bch",
"bacon",
"imon2005",
"imon2005"
]
sett = LinRegOutliers.createRegressionSetting(@formula(calls ~ year), phones)
result = LinRegOutliers.detectOutliers(sett, methods=methods)

for i in 15:21
@test result[:, "hs93"][i] == smiley
end

for i in 18:20
@test result[:, "ks89"][i] == smiley
end

for i in 15:24
@test result[:, "smr98"][i] == smiley
end

for i in 15:21
@test result[:, "lts"][i] == smiley
end

end



@testset "Withour errors" begin

methods = [
"unknown"
]
sett = LinRegOutliers.createRegressionSetting(@formula(calls ~ year), phones)
result = LinRegOutliers.detectOutliers(sett, methods = methods)

for i in 15:21
@test result[:, "hs93"][i] == smiley
end

for i in 18:20
@test result[:, "ks89"][i] == smiley
end

for i in 15:24
@test result[:, "smr98"][i] == smiley
end

for i in 15:21
@test result[:, "lts"][i] == smiley
end

sett = LinRegOutliers.createRegressionSetting(@formula(calls ~ year), phones)

Test.@test_throws ErrorException LinRegOutliers.detectOutliers(sett, methods=methods)

end
end

0 comments on commit b4c0742

Please sign in to comment.