Skip to content

Commit

Permalink
Merge pull request #568 from AltGr/noloop
Browse files Browse the repository at this point in the history
fix(grading): avoid failing on sampling arrays with unique elements
  • Loading branch information
AltGr authored Nov 3, 2023
2 parents cad060f + 6a3ce07 commit 0816f95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/grader/test_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ module Make
if dups then sample else
let prev = Hashtbl.create max_size in
let rec sample_new steps =
if steps = 0 then invalid_arg "sample_array" else
if steps = 0 then sample () else
let s = sample () in
try Hashtbl.find prev s ; sample_new (steps - 1)
with Not_found -> Hashtbl.add prev s () ; s in
Expand Down
4 changes: 3 additions & 1 deletion src/grader/test_lib.mli
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ module type S = sig
sorted.
If [~dups:false] ([true] by default), all elements of generated
array are unique.*)
arrays are unique, or at least try hard to be in a reasonable time:
if the codomain of [sampler] is too small there might still be
duplicates.*)
val sample_array :
?min_size: int -> ?max_size: int -> ?dups: bool -> ?sorted: bool
-> 'a sampler
Expand Down

0 comments on commit 0816f95

Please sign in to comment.