My aggregated monorepo of OCaml code, automaintained

tessera-npy: initial project scaffold

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+80
+11
tessera-npy/dune-project
··· 1 + (lang dune 3.17) 2 + (name tessera-npy) 3 + (generate_opam_files true) 4 + (license ISC) 5 + (package 6 + (name tessera-npy) 7 + (synopsis "Read and write numpy .npy files in OCaml") 8 + (description "A portable OCaml library for parsing the numpy .npy binary format. Supports int8, uint8, float32, and float64 dtypes with arbitrary shapes. Uses Bigarray for zero-copy data representation.") 9 + (depends 10 + (ocaml (>= 5.2)) 11 + (alcotest (and :with-test (>= 0.8)))))
+3
tessera-npy/lib/dune
··· 1 + (library 2 + (name npy) 3 + (public_name tessera-npy))
+26
tessera-npy/lib/npy.ml
··· 1 + type _ dtype = 2 + | Int8 : int dtype 3 + | Uint8 : int dtype 4 + | Float32 : float dtype 5 + | Float64 : float dtype 6 + 7 + type t = { 8 + shape : int array; 9 + fortran_order : bool; 10 + descr : string; 11 + data : string; 12 + } 13 + 14 + let of_string _s = Error "not implemented" 15 + 16 + let shape t = t.shape 17 + 18 + let fortran_order t = t.fortran_order 19 + 20 + let data_int8 _t = None 21 + 22 + let data_uint8 _t = None 23 + 24 + let data_float32 _t = None 25 + 26 + let data_float64 _t = None
+36
tessera-npy/lib/npy.mli
··· 1 + (** Read and write numpy .npy files. *) 2 + 3 + (** {1 Types} *) 4 + 5 + (** Element types supported by this library. *) 6 + type _ dtype = 7 + | Int8 : int dtype 8 + | Uint8 : int dtype 9 + | Float32 : float dtype 10 + | Float64 : float dtype 11 + 12 + (** A parsed .npy file: dtype, shape, and raw data as bytes. *) 13 + type t 14 + 15 + (** {1 Reading} *) 16 + 17 + val of_string : string -> (t, string) result 18 + (** Parse a .npy file from its raw bytes. *) 19 + 20 + val shape : t -> int array 21 + (** The shape of the array. *) 22 + 23 + val fortran_order : t -> bool 24 + (** Whether the data is in Fortran (column-major) order. *) 25 + 26 + val data_int8 : t -> (int, Bigarray.int8_signed_elt, Bigarray.c_layout) Bigarray.Array1.t option 27 + (** Access data as int8 bigarray if the dtype matches. *) 28 + 29 + val data_uint8 : t -> (int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t option 30 + (** Access data as uint8 bigarray if the dtype matches. *) 31 + 32 + val data_float32 : t -> (float, Bigarray.float32_elt, Bigarray.c_layout) Bigarray.Array1.t option 33 + (** Access data as float32 bigarray if the dtype matches. *) 34 + 35 + val data_float64 : t -> (float, Bigarray.float64_elt, Bigarray.c_layout) Bigarray.Array1.t option 36 + (** Access data as float64 bigarray if the dtype matches. *)
+3
tessera-npy/test/dune
··· 1 + (test 2 + (name test_npy) 3 + (libraries tessera-npy alcotest))
+1
tessera-npy/test/test_npy.ml
··· 1 + let () = ()