public void testUByte() { final byte[][] values = new byte[][]{ TestHelper.createUBytes(new short[]{124, 125, 126, 127, 128, 129, 130, 131}), TestHelper.createUBytes(new short[]{125, 127, 129, 131}), TestHelper.createUBytes(new short[]{127, 128, 129}) }; final boolean unsigned = true; final Histogram histogram = new Histogram(new int[6], 125, 130); for (int i = 0; i < values.length; i++) { histogram.aggregate(values[i], unsigned, IndexValidator.TRUE, ProgressMonitor.NULL); } final int[] exp = new int[]{2, 1, 3, 2, 3, 1}; assertEquals("", equal(exp, histogram.getBinCounts())); }
public void testUByte_withValidator() { final byte[][] values = new byte[][]{ TestHelper.createUBytes(new short[]{124, 125, 126, 127, 128, 129, 130, 131}), TestHelper.createUBytes(new short[]{125, 127, 129, 131}), TestHelper.createUBytes(new short[]{127, 128, 129}) }; final boolean unsigned = true; final IndexValidator validator = new IndexValidator() { public boolean validateIndex(int index) { return index % 3 != 0; } }; final Histogram histogram = new Histogram(new int[6], 125, 130); for (int i = 0; i < values.length; i++) { histogram.aggregate(values[i], unsigned, validator, ProgressMonitor.NULL); } final int[] exp = new int[]{1, 1, 1, 2, 3, 0}; assertEquals("", equal(exp, histogram.getBinCounts())); }
public void testComputeRangeGenericUByte() { final boolean unsigned = true; final byte[] uBytes = TestHelper.createUBytes(new short[]{2, 253, 4, 5, 250, 7, 8, 9}); Range range = new Range(); Range.computeRangeGeneric(uBytes, unsigned, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(2, range.getMin(), 1e-10d); assertEquals(253, range.getMax(), 1e-10d); Range.computeRangeGeneric(uBytes, unsigned, _validator, range, ProgressMonitor.NULL); assertEquals(4, range.getMin(), 1e-10d); assertEquals(250, range.getMax(), 1e-10d); }
public void testAggregatingRangeUByte() { final boolean unsigned = true; final byte[] uBytes = TestHelper.createUBytes(new short[]{40, 20, 50, 60, 200, 230}); final Range range = new Range(87, 100); range.aggregate(uBytes, unsigned, IndexValidator.TRUE, ProgressMonitor.NULL); assertEquals(20, range.getMin(), 1e-10); assertEquals(230, range.getMax(), 1e-10); range.setMinMax(87, 100); range.aggregate(uBytes, unsigned, _validator, ProgressMonitor.NULL); assertEquals(40, range.getMin(), 1e-10); assertEquals(200, range.getMax(), 1e-10); }
public void testComputeRangeUByte() { final byte[] uBytes = TestHelper.createUBytes(new short[]{2, 253, 4, 5, 250, 7, 8, 9}); Range range = new Range(); try { Range.computeRangeUByte(uBytes, null, range, ProgressMonitor.NULL); fail("IllegalArgumentException expected because validator is null."); } catch (Exception expected) { } Range.computeRangeUByte(uBytes, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(2, range.getMin(), 1e-10d); assertEquals(253, range.getMax(), 1e-10d); Range.computeRangeUByte(uBytes, _validator, range, ProgressMonitor.NULL); assertEquals(4, range.getMin(), 1e-10d); assertEquals(250, range.getMax(), 1e-10d); }