Convolution extends Filter2D { public Kernel getKernel() { return kernel; } Convolution(DataSource original, Kernel kernel, Mode mode, int... cols); Kernel getKernel();  }
@Test public void testKernel() { Convolution filter = new Convolution(table, kernel, Filter2D.Mode.ZERO, 0, 1); assertEquals(kernel, filter.getKernel()); }
@Test public void testSerialization() throws IOException, ClassNotFoundException { Convolution original = new Convolution(table, kernel, Filter2D.Mode.ZERO, 0, 1); Convolution deserialized = TestUtils.serializeAndDeserialize(original); assertEquals(original.getKernel().size(), deserialized.getKernel().size()); assertEquals(original.getMode(), deserialized.getMode()); assertArrayEquals(original.getColumnTypes(), deserialized.getColumnTypes()); assertEquals(original.getColumnCount(), deserialized.getColumnCount()); assertEquals(original.getRowCount(), deserialized.getRowCount()); for (int row = 0; row < original.getRowCount(); row++) { for (int col = 0; col < original.getColumnCount(); col++) { assertEquals( String.format("Wrong data at col=%d, row=%d.", col, row), original.get(col, row), deserialized.get(col, row)); } } String[] stats = { Statistics.N, Statistics.SUM, Statistics.MEAN, Statistics.VARIANCE }; for (String stat : stats) { assertEquals( original.getStatistics().get(stat), deserialized.getStatistics().get(stat), DELTA); } }