Skip to content

Commit 942493a

Browse files
committed
WIP: ops.run to OpBuilder
1 parent de3e01d commit 942493a

76 files changed

Lines changed: 1584 additions & 1657 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/test/java/net/imagej/ops/coloc/icq/LiICQTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void testICQ() {
5959
final Img<ByteType> img1 = generateByteArrayTestImg(true, 10, 15, 20);
6060
final Img<ByteType> img2 = generateByteArrayTestImg(true, 10, 15, 20);
6161

62-
final Double icqValue = new OpBuilder(ops, "coloc.icq").input(img1, img2).outType(Double.class).apply();
62+
final Double icqValue = op("coloc.icq").input(img1, img2).outType(Double.class).apply();
6363

6464
assertEquals(0.5, icqValue, 0.0);
6565
}
@@ -69,7 +69,7 @@ public void testICQ() {
6969
*/
7070
@Test
7171
public void liPositiveCorrTest() {
72-
final Double icqValue = new OpBuilder(ops, "coloc.icq").input(positiveCorrelationImageCh1, positiveCorrelationImageCh2).outType(Double.class).apply();
72+
final Double icqValue = op("coloc.icq").input(positiveCorrelationImageCh1, positiveCorrelationImageCh2).outType(Double.class).apply();
7373
assertTrue(icqValue > 0.34 && icqValue < 0.35);
7474
}
7575

@@ -79,7 +79,7 @@ public void liPositiveCorrTest() {
7979
*/
8080
@Test
8181
public void liZeroCorrTest() {
82-
final Object icqValue = new OpBuilder(ops, "coloc.icq").input(zeroCorrelationImageCh1, zeroCorrelationImageCh2).apply();
82+
final Object icqValue = op("coloc.icq").input(zeroCorrelationImageCh1, zeroCorrelationImageCh2).apply();
8383

8484
assertTrue(icqValue instanceof Double);
8585
final double icq = (Double) icqValue;
@@ -102,7 +102,7 @@ public void testPValue() {
102102
BiFunction<Iterable<FloatType>, Iterable<FloatType>, Double> op = Functions.match(ops, "coloc.icq",
103103
new Nil<Iterable<FloatType>>() {}, new Nil<Iterable<FloatType>>() {}, new Nil<Double>() {});
104104
PValueResult value = new PValueResult();
105-
new OpBuilder(ops, "coloc.pValue").input(ch1, ch2, op, es).output(value).compute();
105+
op("coloc.pValue").input(ch1, ch2, op, es).output(value).compute();
106106
assertEquals(0.72, value.getPValue(), 0.0);
107107
}
108108

src/test/java/net/imagej/ops/coloc/kendallTau/KendallTauBRankTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void exhaustiveKendallTauBRankTesting() {
105105
//final PairIterator<DoubleType> iter = pairIterator(values1, values2);
106106
final Iterable<Pair<IntType, IntType>> iter = new IterablePair<>(ArrayImgs.ints(values1, n), ArrayImgs.ints(values2, n));
107107
double kendallValue1 = calculateNaive(iter.iterator());
108-
double kendallValue2 = new OpBuilder(ops, "coloc.kendallTau").input(values1, values2).outType(Double.class).apply();
108+
double kendallValue2 = op("coloc.kendallTau").input(values1, values2).outType(Double.class).apply();
109109
if (Double.isNaN(kendallValue1)) {
110110
assertTrue("i: " + i + ", value2: " + kendallValue2, Double.isInfinite(kendallValue2) || Double.isNaN(kendallValue2));
111111
} else {
@@ -128,7 +128,7 @@ public void testPValue() {
128128
BiFunction<Iterable<FloatType>, Iterable<FloatType>, Double> op = Functions.match(ops,
129129
"coloc.kendallTau", nilI, nilI, new Nil<Double>() {});
130130
PValueResult value = new PValueResult();
131-
new OpBuilder(ops, "coloc.pValue").input(ch1, ch2, op, es).output(value).compute();
131+
op("coloc.pValue").input(ch1, ch2, op, es).output(value).compute();
132132
assertEquals(0.75, value.getPValue(), 0.0);
133133
}
134134

@@ -140,7 +140,7 @@ private int pseudoRandom()
140140
}
141141

142142
private <T extends RealType<T>, U extends RealType<U>> void assertTau(final double expected, final Iterable<T> img1, final Iterable<U> img2) {
143-
final double kendallValue = (double) new OpBuilder(ops, "coloc.kendallTau").input(img1, img2).apply();
143+
final double kendallValue = (double) op("coloc.kendallTau").input(img1, img2).apply();
144144
assertEquals(expected, kendallValue, 1e-10);
145145
}
146146

src/test/java/net/imagej/ops/coloc/maxTKendallTau/MTKTTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import net.imglib2.view.Views;
4848

4949
import org.junit.Test;
50-
import org.scijava.ops.core.builder.OpBuilder;
5150
import org.scijava.ops.function.Functions;
5251
import org.scijava.ops.types.Nil;
5352
import org.scijava.thread.ThreadService;
@@ -148,7 +147,7 @@ public void testMTKTnone() {
148147
}
149148
Img<DoubleType> vImage1 = ArrayImgs.doubles(values1, values1.length);
150149
Img<DoubleType> vImage2 = ArrayImgs.doubles(values2, values2.length);
151-
double result = new OpBuilder(ops, "coloc.maxTKendallTau").input(vImage1, vImage2).outType(Double.class).apply();
150+
double result = op("coloc.maxTKendallTau").input(vImage1, vImage2).outType(Double.class).apply();
152151
assertEquals(4.9E-324, result, 0.0);
153152
}
154153

@@ -164,7 +163,7 @@ public void testMTKTall() {
164163
}
165164
Img<DoubleType> vImage1 = ArrayImgs.doubles(values1, values1.length);
166165
Img<DoubleType> vImage2 = ArrayImgs.doubles(values2, values2.length);
167-
double result = (Double) new OpBuilder(ops, "coloc.maxTKendallTau").input(vImage1, vImage2).apply();
166+
double result = (Double) op("coloc.maxTKendallTau").input(vImage1, vImage2).apply();
168167
assertEquals(1.0, result, 0.0);
169168
}
170169

@@ -178,7 +177,7 @@ public void testMTKTrandom() {
178177
0x01234567);
179178
Img<FloatType> ch2 = ColocalisationTest.produceMeanBasedNoiseImage(new FloatType(), 24, 24, mean, spread, sigma,
180179
0x98765432);
181-
double result = (Double) new OpBuilder(ops, "coloc.maxTKendallTau").input(ch1, ch2).apply();
180+
double result = (Double) op("coloc.maxTKendallTau").input(ch1, ch2).apply();
182181
assertEquals(2.710687382741972, result, 0.0);
183182
}
184183

@@ -189,7 +188,7 @@ public void testMTKTimage() {
189188
new long[] { 0, 0, 0 }, new long[] { 20, 20, 0 });
190189
RandomAccessibleInterval<UnsignedByteType> cropCh2 = Views.interval(zeroCorrelationImageCh2,
191190
new long[] { 0, 0, 0 }, new long[] { 20, 20, 0 });
192-
double result = (Double) new OpBuilder(ops, "coloc.maxTKendallTau").input(cropCh1, cropCh2).apply();
191+
double result = (Double) op("coloc.maxTKendallTau").input(cropCh1, cropCh2).apply();
193192
assertEquals(2.562373279563565, result, 0.0);
194193
}
195194

@@ -211,7 +210,7 @@ public void testMTKTpValueNone() {
211210
BiFunction<RandomAccessibleInterval<DoubleType>, RandomAccessibleInterval<DoubleType>, Double> op =
212211
Functions.match(ops, "coloc.maxTKendallTau", new Nil<RandomAccessibleInterval<DoubleType>>() {}, new Nil<RandomAccessibleInterval<DoubleType>>() {}, new Nil<Double>() {});
213212
PValueResult value = new PValueResult();
214-
new OpBuilder(ops, "coloc.pValue").input(vImage1, vImage2, op, 5, es, value).apply();
213+
op("coloc.pValue").input(vImage1, vImage2, op, 5, es, value).apply();
215214
assertEquals(0.0, value.getPValue(), 0.0);
216215
}
217216

@@ -231,7 +230,7 @@ public void testMTKTpValueAll() {
231230
BiFunction<RandomAccessibleInterval<DoubleType>, RandomAccessibleInterval<DoubleType>, Double> op =
232231
Functions.match(ops, "coloc.maxTKendallTau", new Nil<RandomAccessibleInterval<DoubleType>>() {}, new Nil<RandomAccessibleInterval<DoubleType>>() {}, new Nil<Double>() {});
233232
PValueResult value = new PValueResult();
234-
new OpBuilder(ops, "coloc.pValue").input(vImage1, vImage2, op, 5, es, value).apply();
233+
op("coloc.pValue").input(vImage1, vImage2, op, 5, es, value).apply();
235234
assertEquals(0.0, value.getPValue(), 0.0);
236235
}
237236

@@ -249,7 +248,7 @@ public void testMTKTpValueRandom() {
249248
BiFunction<RandomAccessibleInterval<FloatType>, RandomAccessibleInterval<FloatType>, Double> op =
250249
Functions.match(ops, "coloc.maxTKendallTau", new Nil<RandomAccessibleInterval<FloatType>>() {}, new Nil<RandomAccessibleInterval<FloatType>>() {}, new Nil<Double>() {});
251250
PValueResult value = new PValueResult();
252-
new OpBuilder(ops, "coloc.pValue").input(ch1, ch2, op, 10, es, value).apply();
251+
op("coloc.pValue").input(ch1, ch2, op, 10, es, value).apply();
253252
assertEquals(0.2, value.getPValue(), 0.0);
254253
}
255254

@@ -271,7 +270,7 @@ public void testMTKTpValueImage() {
271270
RandomAccessibleInterval<UnsignedByteType> ch1 = ShuffledView.cropAtMin(cropCh1, blockSize);
272271
RandomAccessibleInterval<UnsignedByteType> ch2 = ShuffledView.cropAtMin(cropCh2, blockSize);
273272
PValueResult value = new PValueResult();
274-
new OpBuilder(ops, "coloc.pValue").input(ch1, ch2, op, 5, es, value).apply();
273+
op("coloc.pValue").input(ch1, ch2, op, 5, es).output(value).compute();
275274
assertEquals(0.2, value.getPValue(), 0.0);
276275
}
277276
}

src/test/java/net/imagej/ops/coloc/pValue/DefaultPValueTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private void assertColoc(double expectedPValue, double expectedColocValue, doubl
100100
// new Nil<BiFunction<Iterable<FloatType>, Iterable<FloatType>, Double>>() {}.getType());
101101

102102
PValueResult output = new PValueResult();
103-
new OpBuilder(ops, "coloc.pValue").input(ch1, ch2, op, result.length - 1, es).output(output).compute();
103+
op("coloc.pValue").input(ch1, ch2, op, result.length - 1, es).output(output).compute();
104104
Double actualPValue = output.getPValue();
105105
Double actualColocValue = output.getColocValue();
106106
double[] actualColocValuesArray = output.getColocValuesArray();

src/test/java/net/imagej/ops/coloc/pearsons/DefaultPearsonsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class DefaultPearsonsTest extends ColocalisationTest {
5858
*/
5959
@Test
6060
public void fastPearsonsZeroCorrTest(){
61-
double result = new OpBuilder(ops, "coloc.pearsons").input(zeroCorrelationImageCh1, zeroCorrelationImageCh2).outType(Double.class).apply();
61+
double result = op("coloc.pearsons").input(zeroCorrelationImageCh1, zeroCorrelationImageCh2).outType(Double.class).apply();
6262
assertEquals(0.0, result, 0.05);
6363
}
6464

@@ -68,7 +68,7 @@ public void fastPearsonsZeroCorrTest(){
6868
*/
6969
@Test
7070
public void fastPearsonsPositiveCorrTest() {
71-
double result = new OpBuilder(ops, "coloc.pearsons").input(positiveCorrelationImageCh1, positiveCorrelationImageCh2).outType(Double.class).apply();
71+
double result = op("coloc.pearsons").input(positiveCorrelationImageCh1, positiveCorrelationImageCh2).outType(Double.class).apply();
7272
assertEquals(0.75, result, 0.01);
7373
}
7474

@@ -87,7 +87,7 @@ public void differentMeansTest() {
8787
512, 512, mean, spread, sigma, 0x01234567);
8888
RandomAccessibleInterval<FloatType> ch2 = produceMeanBasedNoiseImage(new FloatType(),
8989
512, 512, mean, spread, sigma, 0x98765432);
90-
double resultFast = new OpBuilder(ops, "coloc.pearsons").input(ch1, ch2).outType(Double.class).apply();
90+
double resultFast = op("coloc.pearsons").input(ch1, ch2).outType(Double.class).apply();
9191
assertEquals(0.0, resultFast, 0.1);
9292

9393
/* If the means are the same, it causes a numerical problem in the classic implementation of Pearson's
@@ -110,7 +110,7 @@ public void testPValue() {
110110
BiFunction<Iterable<FloatType>, Iterable<FloatType>, Double> op =
111111
Functions.match(ops, "coloc.pearsons", new Nil<Iterable<FloatType>>() {}, new Nil<Iterable<FloatType>>() {}, new Nil<Double>() {});
112112
PValueResult value = new PValueResult();
113-
new OpBuilder(ops, "coloc.pValue").input(ch1, ch2, op, es, value).apply();
113+
op("coloc.pValue").input(ch1, ch2, op, es, value).apply();
114114
assertEquals(0.66, value.getPValue(), 0.0);
115115
}
116116

src/test/java/net/imagej/ops/convert/ConvertIIsTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ public class ConvertIIsTest extends AbstractOpTest {
5858
@Before
5959
public void createImages() {
6060
final FinalDimensions dims = FinalDimensions.wrap(new long[] {10, 10});
61-
in = (IterableInterval<ShortType>) new OpBuilder(ops, "create.img").input(dims, new ShortType()).apply();
61+
in = (IterableInterval<ShortType>) op("create.img").input(dims, new ShortType()).apply();
6262
addNoise(in);
63-
out = (Img<ByteType>) new OpBuilder(ops, "create.img").input(dims, new ByteType()).apply();
63+
out = (Img<ByteType>) op("create.img").input(dims, new ByteType()).apply();
6464
}
6565

6666
@Test
6767
public void testClip() {
68-
new OpBuilder(ops, "convert.clip").input(in, out).apply();
68+
op("convert.clip").input(in, out).apply();
6969

7070
final Cursor<ShortType> c = in.localizingCursor();
7171
final RandomAccess<ByteType> ra = out.randomAccess();
@@ -78,7 +78,7 @@ public void testClip() {
7878

7979
@Test
8080
public void testCopy() {
81-
new OpBuilder(ops, "convert.copy").input(in, out).apply();
81+
op("convert.copy").input(in, out).apply();
8282

8383
final Cursor<ShortType> c = in.localizingCursor();
8484
final RandomAccess<ByteType> ra = out.randomAccess();
@@ -92,8 +92,8 @@ public void testCopy() {
9292
// -- Helper methods --
9393

9494
private void addNoise(final IterableInterval<ShortType> image) {
95-
IterableInterval<ShortType> copy = (IterableInterval<ShortType>) new OpBuilder(ops, "copy.img").input(image).apply();
96-
new OpBuilder(ops, "filter.addNoise").input(copy, -32768., 32767., 10000., image).apply();
95+
IterableInterval<ShortType> copy = (IterableInterval<ShortType>) op("copy.img").input(image).apply();
96+
op("filter.addNoise").input(copy, -32768., 32767., 10000., image).apply();
9797
}
9898

9999
private byte clip(final short value) {

src/test/java/net/imagej/ops/convert/ConvertMapTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void testLossless() {
7373
outC1.next().getRealDouble(), 0d);
7474
}
7575

76-
new OpBuilder(ops, "convert.float32").input(in).output(out).compute();
76+
op("convert.float32").input(in).output(out).compute();
7777

7878
// ops.run(Ops.Map.class, out, in, new ComplexToFloat32<UnsignedByteType>());
7979

@@ -96,7 +96,7 @@ public void testLossy() {
9696
final byte[] outArray = { 4, 123, 18, 64, 90, 120, 12, 17, 73 };
9797
final Img<UnsignedByteType> out = generateUnsignedByteImg(outArray);
9898

99-
new OpBuilder(ops, "convert.uint8").input(in).output(out).compute();
99+
op("convert.uint8").input(in).output(out).compute();
100100
// ops.run(Ops.Map.class, out, in, new ComplexToUint8<FloatType>());
101101

102102
final Cursor<FloatType> inC = in.cursor();

src/test/java/net/imagej/ops/copy/CopyArrayImgTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void copyArrayImgNoOutputTest() {
8686
public void copyArrayImgWithOutputTest() {
8787
final Img<UnsignedByteType> output = input.factory().create(input, input.firstElement());
8888

89-
new OpBuilder(ops, "copy.img").input(input).output(output).compute();
89+
op("copy.img").input(input).output(output).compute();
9090

9191
final Cursor<UnsignedByteType> inc = input.cursor();
9292
final Cursor<UnsignedByteType> outc = output.cursor();

src/test/java/net/imagej/ops/copy/CopyIITest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void createData() {
7171

7272
@Test
7373
public void copyRAINoOutputTest() {
74-
RandomAccessibleInterval<DoubleType> output = new OpBuilder(ops, "copy.iterableInterval").input(input)
74+
RandomAccessibleInterval<DoubleType> output = op("copy.iterableInterval").input(input)
7575
.outType(new Nil<RandomAccessibleInterval<DoubleType>>() {}).apply();
7676

7777
Cursor<DoubleType> inc = input.localizingCursor();
@@ -88,7 +88,7 @@ public void copyRAINoOutputTest() {
8888
public void copyTypeTest() {
8989
Img<FloatType> inputFloat = new ArrayImgFactory<>(new FloatType()).create(new int[] { 120, 100 });
9090

91-
Img<FloatType> output = new OpBuilder(ops, "copy.iterableInterval").input(inputFloat)
91+
Img<FloatType> output = op("copy.iterableInterval").input(inputFloat)
9292
.outType(new Nil<Img<FloatType>>() {}).apply();
9393

9494
assertTrue("Should be FloatType.", output.firstElement() instanceof FloatType);
@@ -98,7 +98,7 @@ public void copyTypeTest() {
9898
public void copyRAIWithOutputTest() {
9999
Img<DoubleType> output = input.factory().create(input, input.firstElement());
100100

101-
new OpBuilder(ops, "copy.iterableInterval").input(input).output(output).compute();
101+
op("copy.iterableInterval").input(input).output(output).compute();
102102

103103
final Cursor<DoubleType> inc = input.cursor();
104104
final Cursor<DoubleType> outc = output.cursor();

src/test/java/net/imagej/ops/copy/CopyImgLabelingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void createData() {
7575

7676
@Test
7777
public void copyImgLabeling() {
78-
new OpBuilder(ops, "copy.imgLabeling").input(input).output(copy).compute();
78+
op("copy.imgLabeling").input(input).output(copy).compute();
7979
assertNotNull(copy);
8080

8181
Cursor<LabelingType<String>> inCursor = input.cursor();

0 commit comments

Comments
 (0)