use of gdsc.core.utils.Random in project GDSC-SMLM by aherbert.
the class ImageSourceTest method interlacedImageSourceCanReturnCroppedDataWithGet.
@Test
public void interlacedImageSourceCanReturnCroppedDataWithGet() {
int w = 5;
int h = 3;
float[][] data = createData(w, h, 15);
int start = 4;
int size = 2;
int skip = 1;
Rectangle bounds = new Rectangle(2, 1, 3, 1);
ImageSource source = new InterlacedImageSource(new MemoryImageSource(w, h, data), start, size, skip);
int[] frames = new int[data.length];
for (int i = 0; i < data.length; i++) frames[i] = i + 1;
Random rand = new Random();
rand.shuffle(frames);
int[] expected = new int[] { 4, 5, 7, 8, 10, 11, 13, 14 };
Assert.assertTrue(source.open());
for (int i = 0; i < data.length; i++) {
int frame = frames[i];
Assert.assertTrue(source.isValid(frame));
float[] d = source.get(frame, bounds);
if (isExpected(frame, expected)) {
Assert.assertEquals(bounds.width * bounds.height, d.length);
Assert.assertArrayEquals(crop(data[frame - 1], w, bounds), d, 0);
} else
Assert.assertNull(d);
}
Assert.assertFalse(source.isValid(0));
Assert.assertFalse(source.isValid(data.length + 1));
}
use of gdsc.core.utils.Random in project GDSC-SMLM by aherbert.
the class TraceManagerTest method canTraceMultiplePulseWithFixedCoords.
@Test
public void canTraceMultiplePulseWithFixedCoords() {
Random rand = new Random(30051977);
int maxOffTime = 5;
float[] params = createParams(rand);
Trace trace = new Trace();
for (int i = 0; i < 5; i++) {
trace.add(new PeakResult(i, 0, 0, 0, 0, 0, params, null));
}
for (int i = 0; i < 5; i++) {
trace.add(new PeakResult(i + maxOffTime, 0, 0, 0, 0, 0, params, null));
}
runTracing(0, maxOffTime + 1, trace);
}
use of gdsc.core.utils.Random in project GDSC-SMLM by aherbert.
the class TraceManagerTest method canTraceSinglePulseWithFixedCoords.
@Test
public void canTraceSinglePulseWithFixedCoords() {
Random rand = new Random(30051977);
float[] params = createParams(rand);
Trace trace = new Trace();
for (int i = 0; i < 5; i++) {
trace.add(new PeakResult(i, 0, 0, 0, 0, 0, params, null));
}
runTracing(0, 1, trace);
}
Aggregations