Namespace test fails when adding a new op

imagej-ops
Tags: #<Tag:0x00007fd53e60ef30>

#1

Hi all,

I’m trying to an op to the Morphology namespace, but the namespace test keeps failing with:

[ERROR] Mismatched inputs:
	op = net.imagej.ops.morphology.hollow.Hollow
	method = public net.imglib2.RandomAccessibleInterval net.imagej.ops.morphology.MorphologyNamespace.hollow(net.imglib2.RandomAccessibleInterval,java.lang.Boolean)

In my code I declare an op method:

	@OpMethod(op = net.imagej.ops.morphology.hollow.Hollow.class)
	public <B extends BooleanType<B>> RandomAccessibleInterval<BitType> hollow(
		final RandomAccessibleInterval<B> in, final Boolean excludeEdges)
	{
		@SuppressWarnings("unchecked")
		final RandomAccessibleInterval<BitType> result =
			(RandomAccessibleInterval<BitType>) ops().run(Ops.Morphology.Hollow.class,
				in, excludeEdges);
		return result;
	}

What am I missing?

Best regards,
Richard


#2

After running maven on the hollow branch, I get:

Request:
-	net.imagej.ops.Ops$Morphology$Hollow(
		ArrayImg,
		Boolean)

Candidates:
1. 	(RandomAccessibleInterval out?) =
	net.imagej.ops.morphology.hollow.Hollow(
		RandomAccessibleInterval out?,
==>		RandomAccessibleInterval in,
		Boolean excludeEdges?)
	Inconvertible type: java.lang.Boolean => net.imglib2.RandomAccessibleInterval<capture of ?>

	at net.imagej.ops.morphology.hollow.HollowTest.testEdgeSquareExcludeEdgesFalse(HollowTest.java:167)

So this seems to be because the optional arguments are filled from left to right, and you’re trying to match the Boolean to your second input RandomAccessibleInterval ?!


#3

Yes, it is true to that one of my tests failed in addition to the namespace test failing. I was confused by the op-methods of the extractHoles op. It looked like it had the same signature: a unary op with one optional @Parameter. However, with a fresh(er) set of eyes I noticed that in fact this op extends a different abstract class than mine. I changed my op to binary, fixed the op-methods and now tests pass OK. Thank you for your reply!