Skip to content

Commit dd16e9a

Browse files
authored
Merge pull request #90 from scijava/scijava/scijava-ops-api/migrate-features-to-engine
Minimize and proof SciJava Ops API & SPI
2 parents 753836d + 436fa5a commit dd16e9a

192 files changed

Lines changed: 3101 additions & 3464 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.

‎imagej/imagej-ops2-tutorial/docs/MigratingFromImageJOps.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ To conform `DefaultGaussRAI` to this schema, the following diff should be applie
9696
public void compute(final RandomAccessibleInterval<T> input,
9797
+ final ThreadService threads,
9898
+ final double[] sigmas,
99-
+ @Optional OutOfBoundsFactory<T, RandomAccessibleInterval<T>> outOfBounds,
99+
+ @Nullable OutOfBoundsFactory<T, RandomAccessibleInterval<T>> outOfBounds,
100100
final RandomAccessibleInterval<T> output)
101101
{
102102
```
103103

104-
**Note**: optional parameters are denoted using the `org.scijava.ops.spi.Optional` annotation. Just like in ImageJ Ops, if the user does *not* decide to pass that parameter, it will be assigned to `null`, so leave in any null-checks for optional parameters.
104+
**Note**: nullable parameters are denoted using the `org.scijava.ops.spi.Nullable` annotation. Just like in ImageJ Ops, if the user does *not* decide to pass that parameter, it will be assigned to `null`, so leave in any null-checks for nullable parameters.
105105

106106
## 3 Implementing the right functional interface
107107

@@ -174,7 +174,7 @@ public class DefaultGaussRAI<T extends NumericType<T> & NativeType<T>> implement
174174
public void compute(final RandomAccessibleInterval<T> input,
175175
final ThreadService threads,
176176
final double[] sigmas,
177-
@Optional OutOfBoundsFactory<T, RandomAccessibleInterval<T>> outOfBounds,
177+
@Nullable OutOfBoundsFactory<T, RandomAccessibleInterval<T>> outOfBounds,
178178
final RandomAccessibleInterval<T> output)
179179
{
180180

‎imagej/imagej-ops2-tutorial/src/main/java/module-info.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
requires jama;
6060
requires mines.jtk;
6161

62-
uses org.scijava.ops.api.features.MatchingRoutine;
63-
6462
provides org.scijava.ops.spi.OpCollection with
6563
net.imagej.ops2.tutorial.OpAdaptation,
6664
net.imagej.ops2.tutorial.OpParallelization,

‎imagej/imagej-ops2-tutorial/src/main/java/net/imagej/ops2/tutorial/OpReduction.java‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55

66
import org.scijava.function.Functions;
77
import org.scijava.ops.api.OpEnvironment;
8+
import org.scijava.ops.spi.Nullable;
89
import org.scijava.ops.spi.OpCollection;
910
import org.scijava.ops.spi.OpMethod;
10-
import org.scijava.ops.spi.Optional;
1111

1212
/**
1313
* One powerful feature of SciJava Ops is the ability to transform individual
1414
* Ops to match user requests. In this way, SciJava Ops can satisfy many Op
1515
* calls with just one implementation.
1616
* <p>
1717
* Another transformation is called "reduction". This type of transformation
18-
* allows marked "Optional" parameters to be omitted from Op requests, <b>in a
18+
* allows marked "Nullable" parameters to be omitted from Op requests, <b>in a
1919
* right-to-left order</b>. For example, if the rightmost parameter to an Op is
20-
* marked as Optional, then it can be provided, or omitted, in Op signatures. If
21-
* the rightmost <b>two</b> parameters are both marked as Optional, then both
20+
* marked as Nullable, then it can be provided, or omitted, in Op signatures. If
21+
* the rightmost <b>two</b> parameters are both marked as Nullable, then both
2222
* can be provided, both can be omitted, or only the rightmost parameter can be
2323
* omitted.
2424
* <p>
25-
* Within Ops declaring Optional parameters, omitted parameters are given
25+
* Within Ops declaring Nullable parameters, omitted parameters are given
2626
* {@code null} arguments. The Op is thus responsible for null-checking any
27-
* parameters it declares as Optional.
27+
* parameters it declares as Nullable.
2828
* <p>
2929
* Below, we can see how this works by calling the above Method Op, normally
3030
* requiring three parameters, with only two parameters.
@@ -40,8 +40,8 @@ public class OpReduction implements OpCollection {
4040
* @return the sum of the passed numbers.
4141
*/
4242
@OpMethod(names = "tutorial.reduce", type = Functions.Arity3.class)
43-
public static Double optionalMethod(Double in1, @Optional Double in2,
44-
@Optional Double in3)
43+
public static Double nullableMethod(Double in1, @Nullable Double in2,
44+
@Nullable Double in3)
4545
{
4646
// neither were given
4747
if (in2 == null && in3 == null) {
@@ -74,7 +74,7 @@ public static void main(String... args) {
7474
// -- CALL WITH ALL THREE PARAMETERS -- //
7575

7676
// Ask for an Op of name "tutorial.reduce"
77-
Double noOptional = ops.ternary("tutorial.reduce") //
77+
Double noNullable = ops.ternary("tutorial.reduce") //
7878
// With our two Double inputs
7979
.input(first, second, third) //
8080
// And get a Double out
@@ -85,7 +85,7 @@ public static void main(String... args) {
8585
// -- CALL WITH ONE OPTIONAL PARAMETER -- //
8686

8787
// Ask for an Op of name "tutorial.reduce"
88-
Double oneOptional = ops.binary("tutorial.reduce") //
88+
Double oneNullable = ops.binary("tutorial.reduce") //
8989
// With our two Double inputs
9090
.input(first, second) //
9191
// And get a Double out
@@ -96,7 +96,7 @@ public static void main(String... args) {
9696
// -- CALL WITH TWO OPTIONAL PARAMETERS -- //
9797

9898
// Ask for an Op of name "tutorial.reduce"
99-
Double twoOptional = ops.unary("tutorial.reduce") //
99+
Double twoNullable = ops.unary("tutorial.reduce") //
100100
// With our two Double inputs
101101
.input(first) //
102102
// And get a Double out

‎imagej/imagej-ops2/pom.xml‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@
251251
<!-- SciJava dependencies -->
252252
<dependency>
253253
<groupId>org.scijava</groupId>
254-
<artifactId>parsington</artifactId>
254+
<artifactId>scijava-meta</artifactId>
255+
<version>${project.version}</version>
255256
</dependency>
256257
<dependency>
257258
<groupId>org.scijava</groupId>
@@ -268,11 +269,6 @@
268269
<artifactId>scijava-ops-spi</artifactId>
269270
<version>${project.version}</version>
270271
</dependency>
271-
<dependency>
272-
<groupId>org.scijava</groupId>
273-
<artifactId>scijava-ops-engine</artifactId>
274-
<version>${project.version}</version>
275-
</dependency>
276272
<dependency>
277273
<groupId>org.scijava</groupId>
278274
<artifactId>scijava-function</artifactId>
@@ -313,6 +309,12 @@
313309
<artifactId>junit-jupiter-engine</artifactId>
314310
<scope>test</scope>
315311
</dependency>
312+
<dependency>
313+
<groupId>org.scijava</groupId>
314+
<artifactId>scijava-ops-engine</artifactId>
315+
<version>${project.version}</version>
316+
<scope>test</scope>
317+
</dependency>
316318
<dependency>
317319
<groupId>org.scijava</groupId>
318320
<artifactId>scijava-testutil</artifactId>
@@ -330,11 +332,5 @@
330332
<artifactId>scifio</artifactId>
331333
<scope>test</scope>
332334
</dependency>
333-
<dependency>
334-
<!-- Do not remove - Maven incorrectly identifies it as an unused dependency! -->
335-
<groupId>org.scijava</groupId>
336-
<artifactId>scripting-jython</artifactId>
337-
<scope>test</scope>
338-
</dependency>
339-
</dependencies>
335+
</dependencies>
340336
</project>

‎imagej/imagej-ops2/src/main/java/module-info.java‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
* #L%
2828
*/
2929
open module net.imagej.ops2 {
30-
exports net.imagej.ops2;
31-
30+
// Note that opening this module is necessary to provide runtime access
31+
// from the SciJava Ops Engine module.
32+
3233
requires java.scripting;
3334
requires net.imagej.mesh2;
3435
requires net.imglib2;
@@ -41,9 +42,7 @@
4142
requires org.scijava.function;
4243
requires org.scijava.meta;
4344
requires org.scijava.ops.api;
44-
requires org.scijava.ops.engine;
4545
requires org.scijava.ops.spi;
46-
requires org.scijava.parsington;
4746
requires org.scijava.priority;
4847
requires org.scijava.types;
4948

@@ -64,5 +63,4 @@
6463
net.imagej.ops2.types.OutOfBoundsRandomValueFactoryTypeExtractor,
6564
net.imagej.ops2.types.RAITypeExtractor;
6665

67-
uses org.scijava.ops.api.features.MatchingRoutine;
6866
}

‎imagej/imagej-ops2/src/main/java/net/imagej/ops2/coloc/icq/LiICQ.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
*/
2929
package net.imagej.ops2.coloc.icq;
3030

31-
import java.util.function.BiFunction;
32-
3331
import net.imagej.ops2.coloc.ColocUtil;
3432
import net.imglib2.type.numeric.RealType;
3533
import net.imglib2.type.numeric.real.DoubleType;
@@ -38,8 +36,8 @@
3836

3937
import org.scijava.function.Computers;
4038
import org.scijava.function.Functions;
39+
import org.scijava.ops.spi.Nullable;
4140
import org.scijava.ops.spi.OpDependency;
42-
import org.scijava.ops.spi.Optional;
4341

4442
/**
4543
* This algorithm calculates Li et al.'s ICQ (intensity correlation quotient).
@@ -68,7 +66,8 @@ public class LiICQ<T extends RealType<T>, U extends RealType<U>, V extends RealT
6866
* @return the output
6967
*/
7068
@Override
71-
public Double apply(final Iterable<T> image1, final Iterable<U> image2, @Optional DoubleType mean1, @Optional DoubleType mean2) {
69+
public Double apply(final Iterable<T> image1, final Iterable<U> image2, @Nullable
70+
DoubleType mean1, @Nullable DoubleType mean2) {
7271

7372
if (!ColocUtil.sameIterationOrder(image1, image2))
7473
throw new IllegalArgumentException(

‎imagej/imagej-ops2/src/main/java/net/imagej/ops2/deconvolve/RichardsonLucyC.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.scijava.function.Computers;
4545
import org.scijava.function.Inplaces;
4646
import org.scijava.ops.spi.OpDependency;
47-
import org.scijava.ops.spi.Optional;
47+
import org.scijava.ops.spi.Nullable;
4848

4949
/**
5050
* Richardson Lucy algorithm for (@link RandomAccessibleInterval) (Lucy, L. B.
@@ -138,7 +138,7 @@ public void compute(RandomAccessibleInterval<I> in, RandomAccessibleInterval<K>
138138
Inplaces.Arity1<RandomAccessibleInterval<O>> accelerator,
139139
Computers.Arity1<RandomAccessibleInterval<O>, RandomAccessibleInterval<O>> updateOp,
140140
List<Inplaces.Arity1<RandomAccessibleInterval<O>>> iterativePostProcessingOps,
141-
@Optional RandomAccessibleInterval<O> raiExtendedEstimate,
141+
@Nullable RandomAccessibleInterval<O> raiExtendedEstimate,
142142
RandomAccessibleInterval<O> out) {
143143

144144
// if a starting point for the estimate was not passed in then create

‎imagej/imagej-ops2/src/main/java/net/imagej/ops2/deconvolve/RichardsonLucyF.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
import org.scijava.function.Computers;
4747
import org.scijava.function.Functions;
4848
import org.scijava.function.Inplaces;
49+
import org.scijava.ops.spi.Nullable;
4950
import org.scijava.ops.spi.OpDependency;
50-
import org.scijava.ops.spi.Optional;
5151

5252
/**
5353
* Richardson Lucy function op that operates on (@link RandomAccessibleInterval)
@@ -197,9 +197,9 @@ private void computeFilter(final RandomAccessibleInterval<I> input,
197197
public RandomAccessibleInterval<O> apply(RandomAccessibleInterval<I> input, RandomAccessibleInterval<K> kernel,
198198
O outType, C complexType, Integer maxIterations,
199199
Boolean nonCirculant, Boolean accelerate,
200-
@Optional long[] borderSize,
201-
@Optional OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput,
202-
@Optional OutOfBoundsFactory<K, RandomAccessibleInterval<K>> obfKernel)
200+
@Nullable long[] borderSize,
201+
@Nullable OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput,
202+
@Nullable OutOfBoundsFactory<K, RandomAccessibleInterval<K>> obfKernel)
203203
{
204204
if (obfInput == null)
205205
obfInput = new OutOfBoundsConstantValueFactory<>(Util.getTypeFromInterval(input).createVariable());

‎imagej/imagej-ops2/src/main/java/net/imagej/ops2/deconvolve/RichardsonLucyTVF.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
import org.scijava.function.Computers;
4848
import org.scijava.function.Functions;
4949
import org.scijava.function.Inplaces;
50+
import org.scijava.ops.spi.Nullable;
5051
import org.scijava.ops.spi.OpDependency;
51-
import org.scijava.ops.spi.Optional;
5252

5353
/**
5454
* Richardson Lucy with total variation function op that operates on (@link
@@ -188,9 +188,9 @@ public void computeFilter(final RandomAccessibleInterval<I> input, final RandomA
188188
public RandomAccessibleInterval<O> apply(RandomAccessibleInterval<I> input, RandomAccessibleInterval<K> kernel,
189189
O outType, C complexType, Integer maxIterations,
190190
Boolean nonCirculant, Boolean accelerate, Float regularizationFactor,
191-
@Optional long[] borderSize,
192-
@Optional OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput,
193-
@Optional OutOfBoundsFactory<K, RandomAccessibleInterval<K>> obfKernel)
191+
@Nullable long[] borderSize,
192+
@Nullable OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput,
193+
@Nullable OutOfBoundsFactory<K, RandomAccessibleInterval<K>> obfKernel)
194194
{
195195
if (obfInput == null)
196196
obfInput = new OutOfBoundsConstantValueFactory<>(Util.getTypeFromInterval(input).createVariable());

‎imagej/imagej-ops2/src/main/java/net/imagej/ops2/deconvolve/RichardsonLucyTVUpdate.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
import org.scijava.function.Computers;
4747
import org.scijava.ops.spi.OpDependency;
48-
import org.scijava.ops.spi.Optional;
48+
import org.scijava.ops.spi.Nullable;
4949

5050
/**
5151
* Implements update step for Richardson-Lucy algorithm with total variation
@@ -74,7 +74,8 @@ public class RichardsonLucyTVUpdate<T extends RealType<T> & NativeType<T>, I ext
7474
* @param estimate
7575
*/
7676
@Override
77-
public void compute(final I correction, final Float regularizationFactor, @Optional RandomAccessibleInterval<T> variation, final I estimate) {
77+
public void compute(final I correction, final Float regularizationFactor, @Nullable
78+
RandomAccessibleInterval<T> variation, final I estimate) {
7879

7980
if (variation == null) {
8081
Type<T> type = Util.getTypeFromInterval(correction);

0 commit comments

Comments
 (0)