Skip to content

Commit b4c0742

Browse files
committed
summary throws error when an unknown method name is provided
1 parent 61180fd commit b4c0742

3 files changed

Lines changed: 41 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
- Initial attempt to reduce memory allocations in `lts()`, `lms()`, `hadi92()`, `hadi94()`, `hs93()`, `robcov()`
66
- Replace `@assert` macro with `throw(ErrorException())` in whole code
77
- `depestregression` returns `Dict` instead of a `vector` of betas like other regression methods.
8+
- `summary()` throws `ErrorException` rather than simply prompting with `@error` macro.
9+
810

911

1012
# v0.11.3

src/summary.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ function detectOutliers(X::AbstractMatrix{Float64}, y::AbstractVector{Float64};
118118
result = Int[]
119119
end
120120
else
121-
@error "Method not found " method
122-
result = Int[]
121+
throw(ErrorException("Method not found: $method"))
123122
end
124123
outlier_matrix[:, method] = makeColorColumn(result, n)
125124
end

test/testsummary.jl

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@testset "Summary" begin
2-
smiley = " 😔 "
3-
methods = [
2+
3+
@testset "Withour errors" begin
4+
smiley = " 😔 "
5+
methods = [
46
"hs93",
57
"ks89",
68
"smr98",
@@ -10,25 +12,40 @@
1012
"asm20",
1113
"bch",
1214
"bacon",
13-
"imon2005",
15+
"imon2005"
16+
]
17+
sett = LinRegOutliers.createRegressionSetting(@formula(calls ~ year), phones)
18+
result = LinRegOutliers.detectOutliers(sett, methods=methods)
19+
20+
for i in 15:21
21+
@test result[:, "hs93"][i] == smiley
22+
end
23+
24+
for i in 18:20
25+
@test result[:, "ks89"][i] == smiley
26+
end
27+
28+
for i in 15:24
29+
@test result[:, "smr98"][i] == smiley
30+
end
31+
32+
for i in 15:21
33+
@test result[:, "lts"][i] == smiley
34+
end
35+
36+
end
37+
38+
39+
40+
@testset "Withour errors" begin
41+
42+
methods = [
1443
"unknown"
1544
]
16-
sett = LinRegOutliers.createRegressionSetting(@formula(calls ~ year), phones)
17-
result = LinRegOutliers.detectOutliers(sett, methods = methods)
18-
19-
for i in 15:21
20-
@test result[:, "hs93"][i] == smiley
21-
end
22-
23-
for i in 18:20
24-
@test result[:, "ks89"][i] == smiley
25-
end
26-
27-
for i in 15:24
28-
@test result[:, "smr98"][i] == smiley
29-
end
30-
31-
for i in 15:21
32-
@test result[:, "lts"][i] == smiley
33-
end
45+
46+
sett = LinRegOutliers.createRegressionSetting(@formula(calls ~ year), phones)
47+
48+
Test.@test_throws ErrorException LinRegOutliers.detectOutliers(sett, methods=methods)
49+
50+
end
3451
end

0 commit comments

Comments
 (0)