Skip to content

Commit

Permalink
Add equal functions for comparing various type values.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoj613 committed Jul 1, 2024
1 parent f86284f commit 2d187d8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/codecs/codecs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ module Chain = struct
(fun c acc -> acc >>= ArrayToArray.decode c)
t.a2a (ArrayToBytes.decode y repr' t.a2b)

let equal x y =
x.a2a = y.a2a && x.a2b = y.a2b && x.b2b = y.b2b

let to_yojson t =
[%to_yojson: Yojson.Safe.t list] @@
List.map ArrayToArray.to_yojson t.a2a @
Expand Down
2 changes: 2 additions & 0 deletions lib/codecs/codecs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ module Chain : sig
string ->
(('a, 'b) Ndarray.t, [> error]) result

val equal : t -> t -> bool

val of_yojson : Yojson.Safe.t -> (t, string) result

val to_yojson : t -> Yojson.Safe.t
Expand Down
1 change: 1 addition & 0 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
(:standard -O3))
(preprocess
(pps
ppx_deriving.eq
ppx_deriving.show
ppx_deriving_yojson))
(instrumentation
Expand Down
3 changes: 3 additions & 0 deletions lib/extensions.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module RegularGrid : sig
val grid_shape : t -> int array -> int array
val indices : t -> int array -> int array list
val index_coord_pair : t -> int array -> int array * int array
val equal : t -> t -> bool
val of_yojson : Yojson.Safe.t -> (t, string) result
val to_yojson : t -> Yojson.Safe.t
end
Expand All @@ -18,6 +19,7 @@ module ChunkKeyEncoding : sig
type t
val create : separator -> t
val encode : t -> int array -> string
val equal : t -> t -> bool
val of_yojson : Yojson.Safe.t -> (t, string) result
val to_yojson : t -> Yojson.Safe.t
end
Expand All @@ -41,6 +43,7 @@ module Datatype : sig
| Nativeint
(** A type for the supported data types of a Zarr array. *)

val equal : t -> t -> bool
val of_kind : ('a, 'b) Bigarray.kind -> t
val of_yojson : Yojson.Safe.t -> (t, string) result
val to_yojson : t -> Yojson.Safe.t
Expand Down

0 comments on commit 2d187d8

Please sign in to comment.