Skip to content

Commit

Permalink
Remove superfluous Ndarray module alias
Browse files Browse the repository at this point in the history
  • Loading branch information
zoj613 committed Jul 14, 2024
1 parent 71a2f7c commit 300d8ae
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 40 deletions.
26 changes: 12 additions & 14 deletions lib/codecs/array_to_array.mli
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
open Codecs_intf

module Ndarray = Owl.Dense.Ndarray.Generic

module ArrayToArray : sig
val parse
: ('a, 'b) Util.array_repr ->
arraytoarray ->
(unit, [> error]) result
val compute_encoded_size : int -> arraytoarray -> int
val compute_encoded_representation
: arraytoarray ->
('a, 'b) Util.array_repr ->
(('a, 'b) Util.array_repr, [> error]) result
val encode
: arraytoarray ->
('a, 'b) Ndarray.t ->
(('a, 'b) Ndarray.t, [> error]) result
val decode
: arraytoarray ->
('a, 'b) Ndarray.t ->
(('a, 'b) Ndarray.t, [> error]) result
val compute_encoded_representation :
arraytoarray ->
('a, 'b) Util.array_repr ->
(('a, 'b) Util.array_repr, [> error]) result
val encode :
arraytoarray ->
('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t ->
(('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t, [> error]) result
val decode :
arraytoarray ->
('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t ->
(('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t, [> error]) result
val of_yojson : Yojson.Safe.t -> (arraytoarray, string) result
val to_yojson : arraytoarray -> Yojson.Safe.t
end
20 changes: 9 additions & 11 deletions lib/codecs/array_to_bytes.mli
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
open Codecs_intf

module Ndarray = Owl.Dense.Ndarray.Generic

module ArrayToBytes : sig
val parse
: ('a, 'b) Util.array_repr ->
array_tobytes ->
(unit, [> error]) result
val compute_encoded_size : int -> array_tobytes -> int
val default : array_tobytes
val encode
: ('a, 'b) Ndarray.t ->
array_tobytes ->
(string, [> error]) result
val decode
: string ->
('a, 'b) Util.array_repr ->
array_tobytes ->
(('a, 'b) Ndarray.t, [> error]) result
val encode :
('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t ->
array_tobytes ->
(string, [> error]) result
val decode :
string ->
('a, 'b) Util.array_repr ->
array_tobytes ->
(('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t, [> error]) result
val of_yojson : Yojson.Safe.t -> (array_tobytes, string) result
val to_yojson : array_tobytes -> Yojson.Safe.t
end
2 changes: 0 additions & 2 deletions lib/codecs/bytes_to_bytes.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
open Codecs_intf

module Ndarray = Owl.Dense.Ndarray.Generic

(* https://zarr-specs.readthedocs.io/en/latest/v3/codecs/gzip/v1.0.html *)
module GzipCodec = struct
let to_int = function
Expand Down
2 changes: 0 additions & 2 deletions lib/codecs/bytes_to_bytes.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
open Codecs_intf

module Ndarray = Owl.Dense.Ndarray.Generic

module BytesToBytes : sig
val compute_encoded_size : int -> fixed_bytestobytes -> int
val encode : bytestobytes -> string -> (string, [> error]) result
Expand Down
7 changes: 5 additions & 2 deletions lib/codecs/codecs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ module Chain = struct
{a2a = []; a2b = ArrayToBytes.default; b2b = []}

let encode :
type a b. t -> (a, b) Ndarray.t -> (string, [> error ]) result
type a b.
t ->
(a, b, Bigarray.c_layout) Bigarray.Genarray.t ->
(string, [> error ]) result
= fun t x ->
List.fold_left
(fun acc c -> acc >>= ArrayToArray.encode c) (Ok x) t.a2a
Expand All @@ -96,7 +99,7 @@ module Chain = struct
t ->
(a, b) Util.array_repr ->
string ->
((a, b) Ndarray.t, [> error ]) result
((a, b, Bigarray.c_layout) Bigarray.Genarray.t, [> error]) result
= fun t repr x ->
(* compute the last encoded representation of array->array codec chain.
This becomes the decoded representation of the array->bytes decode
Expand Down
11 changes: 7 additions & 4 deletions lib/codecs/codecs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

include Codecs_intf.Interface

module Ndarray = Owl.Dense.Ndarray.Generic

(** A module containing functions to encode/decode an array chunk using a
predefined set of codecs. *)
module Chain : sig
Expand All @@ -26,12 +24,17 @@ module Chain : sig
(** [encode t x] computes the encoded byte string representation of
array chunk [x]. Returns an error upon failure. *)
val encode :
t -> ('a, 'b) Ndarray.t -> (string, [> error ]) result
t ->
('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t ->
(string, [> error ]) result

(** [decode t repr x] decodes the byte string [x] using codec chain [t]
and decoded representation type [repr]. Returns an error upon failure.*)
val decode :
t -> ('a, 'b) Util.array_repr -> string -> (('a, 'b) Ndarray.t, [> error]) result
t ->
('a, 'b) Util.array_repr ->
string ->
(('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t, [> error ]) result

(** [x = y] returns true if chain [x] is equal to chain [y],
and false otherwise. *)
Expand Down
1 change: 0 additions & 1 deletion lib/codecs/codecs_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type error =
| `CodecChain of string
| `Sharding of int array * int array * string ]

module Ndarray = Owl.Dense.Ndarray.Generic

module type Interface = sig
(** The type of [array -> array] codecs. *)
Expand Down
7 changes: 3 additions & 4 deletions lib/storage/storage_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ module type STORE = sig
val is_member : t -> key -> bool
end

module Ndarray = Owl.Dense.Ndarray.Generic

module type S = sig
type t
(** The storage type. *)
Expand Down Expand Up @@ -122,7 +120,7 @@ module type S = sig
val set_array
: ArrayNode.t ->
Owl_types.index array ->
('a, 'b) Ndarray.t ->
('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t ->
t ->
(unit, [> error | Node.error | Codecs.error ]) result
(** [set_array n s x t] writes n-dimensional array [x] to the slice [s]
Expand All @@ -137,7 +135,8 @@ module type S = sig
Owl_types.index array ->
('a, 'b) Bigarray.kind ->
t ->
(('a, 'b) Ndarray.t, [> error | Node.error | Codecs.error ]) result
(('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t
,[> error | Node.error | Codecs.error ]) result
(** [get_array n s k t] reads an n-dimensional array of size determined
by slice [s] from array node [n]. This operation fails if:
- If there is a problem decoding/encoding node [n] chunks.
Expand Down

0 comments on commit 300d8ae

Please sign in to comment.