@@ -113,10 +113,10 @@ let test_bigarray_of_ctypes_array _ =
113113 [20L ; 40L ; 60L ; 80L ; 100L ]];
114114 [[100L ; 200L ; 300L ; 400L ; 500L ];
115115 [200L ; 400L ; 600L ; 800L ; 1000L ]]] in
116-
116+
117117 let b5 = BA. reshape
118118 (bigarray_of_array genarray BA. int64
119- (Array. from_ptr (castp int64_t (Array. start a5)) 30 ))
119+ (Array. from_ptr (castp int64_t (Array. start a5)) 30 ))
120120 [| 3 ; 2 ; 5 |] in
121121 let () = begin
122122 assert_equal (Array. length a5) (BA.Genarray. nth_dim b5 0 );
@@ -139,7 +139,7 @@ let test_bigarray_of_ctypes_array _ =
139139 [20. ; 40. ; 60. ; 80. ]];
140140 [[100. ; 200. ; 300. ; 400. ];
141141 [200. ; 400. ; 600. ; 800. ]]] in
142-
142+
143143 let b6 = bigarray_of_array array3 BA. float64 a6 in
144144 let () = begin
145145 assert_equal (Array. length a6) (BA.Array3. dim1 b6);
@@ -171,7 +171,7 @@ let test_ctypes_array_of_bigarray _ =
171171
172172 List. iteri (fun i -> BA.Genarray. set b1 [| i |])
173173 [ 6. ; 5. ; 4. ; 3. ; 2. ; 1. ];
174-
174+
175175 for i = 0 to b1_dim - 1 do
176176 assert_equal (BA.Genarray. get b1 [| i |]) a1.(i)
177177 done
@@ -187,7 +187,7 @@ let test_ctypes_array_of_bigarray _ =
187187 List. iteri (fun i ->
188188 fun v -> b2.{i} < - v)
189189 [ 2 ; 4 ; 6 ; 8 ; 10 ; 12 ; 14 ];
190-
190+
191191 for i = 0 to b2_dim - 1 do
192192 assert_equal b2.{i} a2.(i)
193193 done
@@ -300,12 +300,12 @@ let test_ctypes_array_of_bigarray _ =
300300 [{re = 2. ; im = 20. }; {re = 2e2 ; im = 0.0 }];
301301 [{re = 3. ; im = 30. }; {re = 3e2 ; im = 0.0 }];
302302 [{re = 4. ; im = 40. }; {re = 4e2 ; im = 0.0 }]];
303-
303+
304304 [[{re = 5. ; im = 50. }; {re = 5e2 ; im = 0.1 }];
305305 [{re = 6. ; im = 60. }; {re = 6e2 ; im = 0.1 }];
306306 [{re = 7. ; im = 70. }; {re = 7e2 ; im = 0.1 }];
307307 [{re = 8. ; im = 80. }; {re = 8e2 ; im = 0.1 }]];
308-
308+
309309 [[{re = 9. ; im = 90. }; {re = 9e2 ; im = 0.2 }];
310310 [{re = 10. ; im = 100. }; {re = 1e3 ; im = 0.2 }];
311311 [{re = 11. ; im = 110. }; {re = 1.1e3 ; im = 0.2 }];
@@ -320,6 +320,23 @@ let test_ctypes_array_of_bigarray _ =
320320 done
321321 done
322322 end
323+ #if OCAML_VERSION > = (5 , 2 , 0 )
324+ ;
325+ (* Copy of first test case, with float16 instead of float32 *)
326+ let b7_dim = 6 in
327+ let b7 = BA. (Genarray. create float16 c_layout) [| b7_dim |] in
328+ let a7 = array_of_bigarray genarray b7 in
329+ begin
330+ assert_equal (BA.Genarray. nth_dim b7 0 ) (Array. length a1);
331+
332+ List. iteri (fun i -> BA.Genarray. set b7 [| i |])
333+ [ 6. ; 5. ; 4. ; 3. ; 2. ; 1. ];
334+
335+ for i = 0 to b7_dim - 1 do
336+ assert_equal (BA.Genarray. get b7 [| i |]) a7.(i)
337+ done
338+ end
339+ #endif
323340
324341
325342(*
0 commit comments