You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ops/doc/WritingYourOwnOpPackage.md
+60Lines changed: 60 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -276,6 +276,66 @@ class DoubleSizeOp implements Function<double[], Double> {
276
276
277
277
```
278
278
279
+
### Defining Op Progress
280
+
281
+
By adding the `scijava-progress` module, your Op can define and update its progress, providing user value for long-running Ops. To add progress to your Op, you must add the following steps to your Op:
282
+
* Before any significant computation, add the line `Progress.defineTotal(long elements);` where `elements` is the number of "discrete packets" of computation.
283
+
* At convenient spots within your Op, call `Progress.update()` to denote that one packet of computation has finished.
284
+
***Alternatively**, it may be more convenient or performant to call `Progress.update(long numElements)` to denote `numElements` packets have completed at once.
If your Op defines Op dependencies whose progress you'd like to include in your total progress, you can make the following changes.
306
+
* For each Op dependency that you want to track, pass the Hint `"progress.TRACK"` within the `@OpDependency` annotation.
307
+
* Replace `Progress.defineTotal(long elements)` with `Progress.defineTotal(long elements, long subTasks)`, where `subTasks` is the **total** number of times you will invoke Op dependencies annotated with `"progress.TRACK"`.
// There's no significant work here, but we do have 2 subtasks.
331
+
Progress.defineTotal(0, 2);
332
+
finalDouble sum = sumOp.apply(inArray);
333
+
finalDouble size = sizeOp.apply(inArray);
334
+
return sum / size;
335
+
}
336
+
}
337
+
```
338
+
279
339
### Element-wise Ops
280
340
281
341
Simple pixel-wise operations like addition, inversion, and more can be written on a single pixel (i.e. `RealType`) - therefore, SciJava Ops Image takes care to automagically adapt pixel-wise Ops across a wide variety of image types. If you would like to write a pixel-wise Op, we recommend the following structure.
0 commit comments