Skip to content

Commit

Permalink
use checkUnitRange in a couple of places
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaspayette committed Nov 16, 2024
1 parent 483bd9a commit 4559786
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import java.util.List;
import java.util.function.Supplier;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static uk.ac.ox.poseidon.core.MasonUtils.oneOf;
import static uk.ac.ox.poseidon.core.utils.Preconditions.checkUnitRange;

public class EpsilonGreedyChooser<O> implements Supplier<O> {

Expand All @@ -49,11 +49,7 @@ public EpsilonGreedyChooser(
this.options = ImmutableList.copyOf(options);
this.optionValues = checkNotNull(optionValues);
this.evaluator = checkNotNull(evaluator);
checkArgument(
epsilon >= 0 && epsilon <= 1,
"epsilon must be between 0 and 1"
);
this.epsilon = epsilon;
this.epsilon = checkUnitRange(epsilon, "epsilon");
this.rng = checkNotNull(rng);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import java.time.Duration;

import static com.google.common.base.Preconditions.checkArgument;
import static uk.ac.ox.poseidon.core.utils.Preconditions.checkUnitRange;

public class FixedBiomassProportionGear implements FishingGear<Biomass> {

Expand All @@ -36,8 +36,7 @@ public FixedBiomassProportionGear(
final double proportion,
final Duration duration
) {
checkArgument(proportion >= 0 && proportion <= 1);
this.proportion = proportion;
this.proportion = checkUnitRange(proportion, "proportion");
this.duration = duration;
}

Expand Down

0 comments on commit 4559786

Please sign in to comment.