public void testUShort() { final short[][] values = new short[][]{ TestHelper.createUShorts(new int[]{32764, 32765, 32766, 32767, 32768, 32769, 32770, 32771}), TestHelper.createUShorts(new int[]{32765, 32767, 32769, 32771}), TestHelper.createUShorts(new int[]{32767, 32768, 32769}) }; final boolean unsigned = true; final Histogram histogram = new Histogram(new int[6], 32765, 32770); 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 testUShort_withValidator() { final short[][] values = new short[][]{ TestHelper.createUShorts(new int[]{32764, 32765, 32766, 32767, 32768, 32769, 32770, 32771}), TestHelper.createUShorts(new int[]{32765, 32767, 32769, 32771}), TestHelper.createUShorts(new int[]{32767, 32768, 32769}) }; 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], 32765, 32770); 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 testComputeRangeGenericUShort() { final boolean unsigned = true; final short[] uShorts = TestHelper.createUShorts(new int[]{2, 65533, 4, 5, 65530, 7, 8, 9}); Range range = new Range(); Range.computeRangeGeneric(uShorts, unsigned, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(2, range.getMin(), 1e-10d); assertEquals(65533, range.getMax(), 1e-10d); Range.computeRangeGeneric(uShorts, unsigned, _validator, range, ProgressMonitor.NULL); assertEquals(4, range.getMin(), 1e-10d); assertEquals(65530, range.getMax(), 1e-10d); }
public void testComputeRangeUShort() { final short[] uShorts = TestHelper.createUShorts(new int[]{2, 65533, 4, 5, 65530, 7, 8, 9}); Range range = new Range(); Range.computeRangeUShort(uShorts, IndexValidator.TRUE, range, ProgressMonitor.NULL); assertEquals(2, range.getMin(), 1e-10d); assertEquals(65533, range.getMax(), 1e-10d); Range.computeRangeUShort(uShorts, _validator, range, ProgressMonitor.NULL); assertEquals(4, range.getMin(), 1e-10d); assertEquals(65530, range.getMax(), 1e-10d); }
public void testAggregatingRangeUShort() { final boolean unsigned = true; final short[] uShorts = TestHelper.createUShorts(new int[]{40, 20, 50, 30000, 40000, 50000}); final Range range = new Range(87, 100); range.aggregate(uShorts, unsigned, IndexValidator.TRUE, ProgressMonitor.NULL); assertEquals(20, range.getMin(), 1e-10); assertEquals(50000, range.getMax(), 1e-10); range.setMinMax(87, 100); range.aggregate(uShorts, unsigned, _validator, ProgressMonitor.NULL); assertEquals(40, range.getMin(), 1e-10); assertEquals(40000, range.getMax(), 1e-10); }