Skip to content

Commit 025dd2d

Browse files
committed
Add parameter checks to stats ops
1 parent db31640 commit 025dd2d

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

scijava-ops-image/src/main/java/org/scijava/ops/image/stats/DefaultPercentile.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public class DefaultPercentile<I extends RealType<I>, O extends RealType<O>>
6262
*/
6363
@Override
6464
public void compute(final Iterable<I> input, final Double percent, final O output) {
65+
if (percent < 0 || percent > 100) {
66+
throw new IllegalArgumentException(
67+
"Percent must be between 0 and 100 (inclusive) but was " + percent);
68+
}
6569
op.compute(input, percent / 100, output);
6670
}
6771
}

scijava-ops-image/src/main/java/org/scijava/ops/image/stats/DefaultQuantile.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public class DefaultQuantile<I extends RealType<I>, O extends RealType<O>>
6464
public void compute(final Iterable<I> input, final Double quantile,
6565
final O output)
6666
{
67+
if (quantile < 0 || quantile > 1) {
68+
throw new IllegalArgumentException(
69+
"Quantile must be between 0 and 1 (inclusive) but is " + quantile);
70+
}
71+
6772
final ArrayList<Double> statistics = new ArrayList<>();
6873

6974
final Iterator<I> it = input.iterator();

0 commit comments

Comments
 (0)