Skip to content

Commit 6230d45

Browse files
committed
SimplificationUtils: add isIdentity method
Simple helper method to check if a RichOp is an identity op
1 parent f5ea08e commit 6230d45

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scijava-ops-engine/src/main/java/org/scijava/ops/engine/matcher/simplify/SimplificationUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ public static SimplifiedOpInfo simplifyInfo(OpEnvironment env, OpInfo info) {
255255
.computer());
256256
}
257257

258+
/**
259+
* Helper method to check if an op is an "identity" op - i.e. a naive wrapper
260+
* that does no modification to its base op.
261+
*
262+
* @param op {@link RichOp} to check
263+
* @return {@code true} iff the op is an identity op
264+
*/
265+
public static boolean isIdentity(RichOp<?> op) {
266+
return Ops.info(op).names().contains("engine.identity");
267+
}
268+
258269
private static Nil<?> outType(Type originalOutput,
259270
RichOp<Function<?, ?>> outputSimplifier)
260271
{

0 commit comments

Comments
 (0)