Closed frauzufall closed 5 years ago
Yeah, it's super confusing. ☹️
Firstly, the SpecialOp
documentation was wrong. I fixed it with e201033d1e83488a98a0a052af674f00e0c9ac88.
Secondly: the order of parameters to the compute
method is separate from the order of op parameters in general. For example, a unary computer op that extends AbstractUnaryComputerOp
will end up with parameters declared in the order (out, in, a, b, c, d, ...), where a
, b
, etc., are the additional parameters defined in the op itself, and out
and in
are the base parameters defined in AbstractUnaryComputerOp
.
The takeaway is: when calling a computer via the run
method, you need to write run(out, in, a, b, c, d, ...)
. Whereas when calling it via the type-safe compute
method, you need to write compute(in, out)
.
The new version of SciJava Ops, due later this year, fixes this confusion, mapping unary functions and computers to run(in, out)
, binary to run(in1, in2, out)
, and so forth.
I have an issue with the order of input and output parameters of ComputerOps and HybridCFs.
The table in the JavaDoc of SpecialOps says it's
void compute(O, I)
for aUnaryComputerOp
. The source code ofUnaryComputerOp
sayscompute(I input, O output)
, same for the order of the generics in the class definition inAbstractUnaryOp
(implements UnaryComputerOp<I, O>
).I tested it and it seems to execute them as output first, input second, see this example:
This is the output:
As far as I can guess without digging more into it the order is determined by the order of parameters in
AbstractUnaryComputerOp
andAbstractUnaryHybridC
(same for the binary ops).