Search in sources :

Example 61 with SeededTest

use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.

the class FastLogTest method canTestFloatSpeed.

@SpeedTag
@SeededTest
void canTestFloatSpeed(RandomSeed seed) {
    // No assertions, this is just a report
    Assumptions.assumeTrue(logger.isLoggable(Level.INFO));
    Assumptions.assumeTrue(TestSettings.allow(TestComplexity.MEDIUM));
    final UniformRandomProvider rng = RngUtils.create(seed.getSeed());
    final float[] x = new float[1000000];
    for (int i = 0; i < x.length; i++) {
        x[i] = nextUniformFloat(rng);
    }
    final TimingService ts = new TimingService(5);
    ts.execute(new FloatTimingTask(new TestLog(new MathLog()), 0, x));
    ts.execute(new FloatTimingTask(new TestLog(new FastMathLog()), 0, x));
    for (final int q : new int[] { 11 }) {
        final int n = 23 - q;
        final IcsiFastLog fl = IcsiFastLog.create(n, DataType.FLOAT);
        ts.execute(new FloatTimingTask(new TestLog(fl), q, x));
        ts.execute(new FloatTimingTask(new TestFastLog(fl), q, x));
        final FFastLog ff = new FFastLog(n);
        ts.execute(new FloatTimingTask(new TestLog(ff), q, x));
        ts.execute(new FloatTimingTask(new TestFastLog(ff), q, x));
        final DFastLog df = new DFastLog(n);
        ts.execute(new FloatTimingTask(new TestLog(df), q, x));
        ts.execute(new FloatTimingTask(new TestFastLog(df), q, x));
        final TurboLog tf = new TurboLog(n);
        ts.execute(new FloatTimingTask(new TestLog(tf), q, x));
        ts.execute(new FloatTimingTask(new TestFastLog(tf), q, x));
        // TurboLog2 tf2 = new TurboLog2(n);
        // ts.execute(new FloatTimingTask(new TestLog(tf2), q, x));
        // ts.execute(new FloatTimingTask(new TestFastLog(tf2), q, x));
        // For the same precision we can reduce n
        final TurboLog2 tf3 = new TurboLog2(n - 1);
        ts.execute(new FloatTimingTask(new TestLog(tf3), q + 1, x));
        ts.execute(new FloatTimingTask(new TestFastLog(tf3), q + 1, x));
    }
    final int size = ts.getSize();
    ts.repeat(size);
    logger.info(ts.getReport(size));
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) TimingService(uk.ac.sussex.gdsc.test.utils.TimingService) SpeedTag(uk.ac.sussex.gdsc.test.junit5.SpeedTag) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Example 62 with SeededTest

use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.

the class AreaAverageFilterTest method areaAverageUsingSumsInternalCorrectlyInterpolatesBetweenBlocks.

@SeededTest
void areaAverageUsingSumsInternalCorrectlyInterpolatesBetweenBlocks(RandomSeed seed) {
    final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
    final int max = 50;
    final float[] data = createData(rg, max, max);
    final AreaAverageFilter filter = new AreaAverageFilter();
    filter.setSimpleInterpolation(false);
    final int n = 30;
    final float[][] results = new float[n + 1][];
    final double[] w = new double[n + 1];
    int count = 0;
    for (int i = 0; i <= n; i++) {
        w[count] = i / 10.0;
        results[count] = data.clone();
        filter.areaAverageUsingSumsInternal(results[count], max, max, w[count]);
        count++;
    }
    checkInterpolation(max, n, results, count);
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Example 63 with SeededTest

use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.

the class AreaAverageFilterTest method areaAverageUsingSumsCorrectlyInterpolatesBetweenBlocks.

@SeededTest
void areaAverageUsingSumsCorrectlyInterpolatesBetweenBlocks(RandomSeed seed) {
    final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
    final int max = 50;
    final float[] data = createData(rg, max, max);
    final AreaAverageFilter filter = new AreaAverageFilter();
    filter.setSimpleInterpolation(false);
    final int n = 30;
    final float[][] results = new float[n + 1][];
    final double[] w = new double[n + 1];
    int count = 0;
    for (int i = 0; i <= n; i++) {
        w[count] = i / 10.0;
        results[count] = data.clone();
        filter.areaAverageUsingSums(results[count], max, max, w[count]);
        count++;
    }
    checkInterpolation(max, n, results, count);
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Example 64 with SeededTest

use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.

the class TraceManagerTest method canTraceSinglePulseWithMovingCoords.

@SeededTest
void canTraceSinglePulseWithMovingCoords(RandomSeed seed) {
    final UniformRandomProvider rand = RngUtils.create(seed.getSeed());
    final float distance = 0.5f;
    final float[] params = createParams(rand);
    final Trace trace = new Trace();
    for (int i = 0; i < 5; i++) {
        move(rand, params, distance);
        trace.add(new PeakResult(i, 0, 0, 0, 0, 0, 0, params, null));
    }
    runTracing(rand, distance, 1, trace);
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Example 65 with SeededTest

use of uk.ac.sussex.gdsc.test.junit5.SeededTest in project GDSC-SMLM by aherbert.

the class TraceManagerTest method canTraceSinglePulseWithFixedCoords.

@SeededTest
void canTraceSinglePulseWithFixedCoords(RandomSeed seed) {
    final UniformRandomProvider rand = RngUtils.create(seed.getSeed());
    final float[] params = createParams(rand);
    final Trace trace = new Trace();
    for (int i = 0; i < 5; i++) {
        trace.add(new PeakResult(i, 0, 0, 0, 0, 0, 0, params, null));
    }
    runTracing(rand, 0, 1, trace);
}
Also used : UniformRandomProvider(org.apache.commons.rng.UniformRandomProvider) SeededTest(uk.ac.sussex.gdsc.test.junit5.SeededTest)

Aggregations

SeededTest (uk.ac.sussex.gdsc.test.junit5.SeededTest)172 UniformRandomProvider (org.apache.commons.rng.UniformRandomProvider)142 DoubleDoubleBiPredicate (uk.ac.sussex.gdsc.test.api.function.DoubleDoubleBiPredicate)18 Rectangle (java.awt.Rectangle)12 SpeedTag (uk.ac.sussex.gdsc.test.junit5.SpeedTag)12 TimingService (uk.ac.sussex.gdsc.test.utils.TimingService)12 SharedStateContinuousSampler (org.apache.commons.rng.sampling.distribution.SharedStateContinuousSampler)7 TDoubleArrayList (gnu.trove.list.array.TDoubleArrayList)6 FloatProcessor (ij.process.FloatProcessor)6 ErfGaussian2DFunction (uk.ac.sussex.gdsc.smlm.function.gaussian.erf.ErfGaussian2DFunction)6 DummyGradientFunction (uk.ac.sussex.gdsc.smlm.function.DummyGradientFunction)5 SingleFreeCircularErfGaussian2DFunction (uk.ac.sussex.gdsc.smlm.function.gaussian.erf.SingleFreeCircularErfGaussian2DFunction)5 TimingResult (uk.ac.sussex.gdsc.test.utils.TimingResult)5 ArrayList (java.util.ArrayList)4 Gaussian2DFunction (uk.ac.sussex.gdsc.smlm.function.gaussian.Gaussian2DFunction)4 MixtureMultivariateGaussianDistribution (uk.ac.sussex.gdsc.smlm.math3.distribution.fitting.MultivariateGaussianMixtureExpectationMaximization.MixtureMultivariateGaussianDistribution)4 MultivariateGaussianDistribution (uk.ac.sussex.gdsc.smlm.math3.distribution.fitting.MultivariateGaussianMixtureExpectationMaximization.MixtureMultivariateGaussianDistribution.MultivariateGaussianDistribution)4 FloatFloatBiPredicate (uk.ac.sussex.gdsc.test.api.function.FloatFloatBiPredicate)4 MultivariateNormalMixtureExpectationMaximization (org.apache.commons.math3.distribution.fitting.MultivariateNormalMixtureExpectationMaximization)3 DoubleEquality (uk.ac.sussex.gdsc.core.utils.DoubleEquality)3