From 455978629fbfe1a402235560cc113a900227438c Mon Sep 17 00:00:00 2001 From: Nicolas Payette Date: Sat, 16 Nov 2024 12:32:30 +0000 Subject: [PATCH] use checkUnitRange in a couple of places --- .../agents/behaviours/choices/EpsilonGreedyChooser.java | 8 ++------ .../agents/vessels/gears/FixedBiomassProportionGear.java | 5 ++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/agents/src/main/java/uk/ac/ox/poseidon/agents/behaviours/choices/EpsilonGreedyChooser.java b/agents/src/main/java/uk/ac/ox/poseidon/agents/behaviours/choices/EpsilonGreedyChooser.java index 456850aba..1855e2f35 100644 --- a/agents/src/main/java/uk/ac/ox/poseidon/agents/behaviours/choices/EpsilonGreedyChooser.java +++ b/agents/src/main/java/uk/ac/ox/poseidon/agents/behaviours/choices/EpsilonGreedyChooser.java @@ -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 implements Supplier { @@ -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); } diff --git a/agents/src/main/java/uk/ac/ox/poseidon/agents/vessels/gears/FixedBiomassProportionGear.java b/agents/src/main/java/uk/ac/ox/poseidon/agents/vessels/gears/FixedBiomassProportionGear.java index 992c2c7dc..4ca0b1f2c 100644 --- a/agents/src/main/java/uk/ac/ox/poseidon/agents/vessels/gears/FixedBiomassProportionGear.java +++ b/agents/src/main/java/uk/ac/ox/poseidon/agents/vessels/gears/FixedBiomassProportionGear.java @@ -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 { @@ -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; }