Skip to content

Commit

Permalink
Plotting test: Fix lower bounds error (OCaml < 4.13)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Sep 26, 2024
1 parent 4f70815 commit 1422acf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/plotting_half_moons.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,23 @@ end

let noise () = Rand.float_range (-0.1) 0.1

(* [Array.split] only available since OCaml 4.12. *)
let array_split x =
let a0, b0 = x.(0) in
let n = Array.length x in
let a = Array.make n a0 in
let b = Array.make n b0 in
for i = 1 to n - 1 do
let ai, bi = x.(i) in
a.(i) <- ai;
b.(i) <- bi
done;
a, b

(* This tests the printbox-ext-plot extension. *)
let moons data_len =
let npairs = data_len / 2 in
Array.split
array_split
(Array.init npairs (fun _pos ->
let i = Rand.int npairs in
let v = Float.(of_int (i / 2) *. pi /. of_int npairs) in
Expand Down

0 comments on commit 1422acf

Please sign in to comment.