File tree 3 files changed +19
-51
lines changed
unittests/megamek/ai/neuralnetwork
3 files changed +19
-51
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ public float[] predict(float[] inputVector) {
125
125
return resultArrayFromTensors (outputTensors );
126
126
}
127
127
} catch (Exception e ) {
128
- logger .error ("Prediction failed, there is no recourse from this " , e );
128
+ logger .error ("Prediction failed due to an unexpected error " , e );
129
129
throw new RuntimeException ("Failed to make prediction: " + e .getMessage (), e );
130
130
}
131
131
}
Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ private static Collection<TestValue> loadTestValues() {
163
163
*/
164
164
private static MovementClassification getMovementClassificationFromSplitLine (String [] values ) {
165
165
// The last value in the line is the classification
166
- return MovementClassification .fromValue (Integer . parseInt (values [values .length -1 ]));
166
+ return MovementClassification .fromValue (parseInt (values [values .length -1 ]));
167
167
}
168
168
169
169
/**
@@ -175,9 +175,24 @@ private static float[] getInputsFromSplitLine(String[] values) {
175
175
// The last value in the line is the classification, so we don't want it in the input value
176
176
float [] entry = new float [values .length -1 ];
177
177
for (int i = 0 ; i < values .length -1 ; i ++) {
178
- entry [i ] = Float . parseFloat (values [i ]);
178
+ entry [i ] = parseFloat (values [i ]);
179
179
}
180
180
return entry ;
181
181
}
182
- // endregion TestSetup
182
+
183
+ private static float parseFloat (String value ) {
184
+ try {
185
+ return Float .parseFloat (value );
186
+ } catch (NumberFormatException e ) {
187
+ throw new IllegalArgumentException ("Invalid float value: " + value + " Possibly invalid test file" , e );
188
+ }
189
+ }
190
+
191
+ private static int parseInt (String value ) {
192
+ try {
193
+ return Integer .parseInt (value );
194
+ } catch (NumberFormatException e ) {
195
+ throw new IllegalArgumentException ("Invalid int value: " + value + " Possibly invalid test file" , e );
196
+ }
197
+ }
183
198
}
You can’t perform that action at this time.
0 commit comments