From 295fdc1b6a2a1580e9e5b0dfb14df4b6ffce0418 Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Fri, 4 Oct 2024 12:10:41 +0100 Subject: [PATCH] Added checks as @devmotion requested --- src/sample.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sample.jl b/src/sample.jl index 7227029..e339ce3 100644 --- a/src/sample.jl +++ b/src/sample.jl @@ -265,6 +265,13 @@ function mcmcsample( initial_state=nothing, kwargs..., ) + # Check the number of requested samples. + N > 0 || error("the number of samples must be ≥ 1") + discard_initial >= 0 || + throw(ArgumentError("number of discarded samples must be non-negative")) + num_warmup >= 0 || + throw(ArgumentError("number of warm-up samples must be non-negative")) + # Determine how many samples to drop from `num_warmup` and the # main sampling process before we start saving samples. discard_from_warmup = min(num_warmup, discard_initial)