aherbert commented on code in PR #216:
URL: https://github.com/apache/commons-math/pull/216#discussion_r1001090847
##########
commons-math-neuralnet/src/test/java/org/apache/commons/math4/neuralnet/twod/NeuronSquareMesh2DTest.java:
##########
@@ -35,33 +35,39 @@
import org.apache.commons.math4.neuralnet.Network;
import org.apache.commons.math4.neuralnet.Neuron;
import org.apache.commons.math4.neuralnet.SquareNeighbourhood;
+import org.junit.jupiter.api.function.Executable;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Tests for {@link NeuronSquareMesh2D} and {@link Network} functionality for
* a two-dimensional network.
*/
public class NeuronSquareMesh2DTest {
+
private final UniformRandomProvider rng =
RandomSource.SPLIT_MIX_64.create();
private final FeatureInitializer init =
FeatureInitializerFactory.uniform(rng, 0, 2);
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testMinimalNetworkSize1() {
final FeatureInitializer[] initArray = {init};
- new NeuronSquareMesh2D(1, false,
- 2, false,
- SquareNeighbourhood.VON_NEUMANN,
- initArray);
+ final Executable testMethod = () -> new NeuronSquareMesh2D(1, false,
Review Comment:
Again, remove `Executable`. It is good practice to have only one potential
source for the exception inside the assertThrows lambda. E.g. this is bad as
the exception could be from either line:
```Java
assertThrows(IllegalArgumentException.class, () -> {
ClassA a = new ClassA();
ClassB b = new ClassB(a);
});
```
This would be where we create object `a` outside the assertThrows and then
isolate where we expect the exception (from `b`).
Since we have a clean lambda function here then just put it in assertThrows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]