Skip to content

Commit 20b3fa2

Browse files
committed
Avoid potential fall-throughs in RegressionTest
1 parent 5a8c514 commit 20b3fa2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/test/java/de/bwaldvogel/liblinear/RegressionTest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,56 +70,74 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType,
7070
return 0.84184;
7171
case 1:
7272
return regularizeBias ? 0.84552 : 0.84414;
73+
default:
74+
throw new IllegalArgumentException("Unexpected bias: " + bias);
7375
}
7476
case L2R_L2LOSS_SVC_DUAL:
7577
switch (bias) {
7678
case -1:
7779
return 0.84368;
7880
case 1:
7981
return 0.85241;
82+
default:
83+
throw new IllegalArgumentException("Unexpected bias: " + bias);
8084
}
8185
case L2R_L2LOSS_SVC:
8286
switch (bias) {
8387
case -1:
8488
return 0.84276;
8589
case 1:
8690
return regularizeBias ? 0.85057 : 0.85149;
91+
default:
92+
throw new IllegalArgumentException("Unexpected bias: " + bias);
8793
}
8894
case L2R_L1LOSS_SVC_DUAL:
8995
switch (bias) {
9096
case -1:
9197
return 0.83494;
9298
case 1:
9399
return 0.83402;
100+
default:
101+
throw new IllegalArgumentException("Unexpected bias: " + bias);
94102
}
95103
case MCSVM_CS:
96104
switch (bias) {
97105
case -1:
98106
return 0.8377;
99107
case 1:
100108
return 0.83862;
109+
default:
110+
throw new IllegalArgumentException("Unexpected bias: " + bias);
101111
}
102112
case L1R_L2LOSS_SVC:
103113
switch (bias) {
104114
case -1:
105115
return 0.8478;
106116
case 1:
107117
return regularizeBias ? 0.8478 : 0.84782;
118+
default:
119+
throw new IllegalArgumentException("Unexpected bias: " + bias);
108120
}
109121
case L1R_LR:
110122
switch (bias) {
111123
case -1:
112124
return 0.8473;
113125
case 1:
114126
return regularizeBias ? 0.84782 : 0.84598;
127+
default:
128+
throw new IllegalArgumentException("Unexpected bias: " + bias);
115129
}
116130
case L2R_LR_DUAL:
117131
switch (bias) {
118132
case -1:
119133
return 0.8423;
120134
case 1:
121135
return 0.8492;
136+
default:
137+
throw new IllegalArgumentException("Unexpected bias: " + bias);
122138
}
139+
default:
140+
throw new IllegalArgumentException("Unexpected solverType: " + solverType);
123141
}
124142
case "dna.scale":
125143
switch (solverType) {
@@ -129,55 +147,73 @@ private static Double getExpectedAccuracy(String dataset, SolverType solverType,
129147
return 0.94941;
130148
case 1:
131149
return regularizeBias ? 0.950253 : 0.951096;
150+
default:
151+
throw new IllegalArgumentException("Unexpected bias: " + bias);
132152
}
133153
case L2R_L2LOSS_SVC_DUAL:
134154
switch (bias) {
135155
case -1:
136156
case 1:
137157
return 0.9452;
158+
default:
159+
throw new IllegalArgumentException("Unexpected bias: " + bias);
138160
}
139161
case L2R_L2LOSS_SVC:
140162
switch (bias) {
141163
case -1:
142164
return 0.94941;
143165
case 1:
144166
return 0.95194;
167+
default:
168+
throw new IllegalArgumentException("Unexpected bias: " + bias);
145169
}
146170
case L2R_L1LOSS_SVC_DUAL:
147171
switch (bias) {
148172
case -1:
149173
return 0.94688;
150174
case 1:
151175
return 0.94604;
176+
default:
177+
throw new IllegalArgumentException("Unexpected bias: " + bias);
152178
}
153179
case MCSVM_CS:
154180
switch (bias) {
155181
case -1:
156182
return 0.9292;
157183
case 1:
158184
return 0.92749;
185+
default:
186+
throw new IllegalArgumentException("Unexpected bias: " + bias);
159187
}
160188
case L1R_L2LOSS_SVC:
161189
switch (bias) {
162190
case -1:
163191
return 0.9553;
164192
case 1:
165193
return regularizeBias ? 0.956998 : 0.95363;
194+
default:
195+
throw new IllegalArgumentException("Unexpected bias: " + bias);
166196
}
167197
case L1R_LR:
168198
switch (bias) {
169199
case -1:
170200
return 0.9536;
171201
case 1:
172202
return regularizeBias ? 0.95194 : 0.95278;
203+
default:
204+
throw new IllegalArgumentException("Unexpected bias: " + bias);
173205
}
174206
case L2R_LR_DUAL:
175207
switch (bias) {
176208
case -1:
177209
return 0.9486;
178210
case 1:
179211
return 0.94941;
212+
default:
213+
throw new IllegalArgumentException("Unexpected bias: " + bias);
180214
}
215+
default:
216+
throw new IllegalArgumentException("Unexpected solverType: " + solverType);
181217
}
182218
default:
183219
throw new IllegalArgumentException("Unknown expectation: " + dataset + ", " + solverType + ", " + bias);

0 commit comments

Comments
 (0)