text stringlengths 12 786k |
|---|
let catch_s ( ? catch_only = fun _ -> true ) f = Lwt . catch f ( function | ( Stack_overflow | Out_of_memory ) as e -> raise e | e -> if catch_only e then Lwt . return_unit else raise e ) |
let aei = Alcotest . check Alcotest . int |
let aes = Alcotest . check Alcotest . string |
let aeso = Alcotest . check Alcotest . ( option string ) |
let aesl = Alcotest . check Alcotest . ( list string ) |
let aessl = Alcotest . check Alcotest . ( list ( pair string string ) ) |
let aeb = Alcotest . check Alcotest . bool |
let t_header = Alcotest . testable ( fun fmt h -> let sexp = Cohttp . Header . sexp_of_t h in Sexplib0 . Sexp . pp_hum fmt sexp ) ( fun x y -> Cohttp . Header . compare x y = 0 ) |
let aeh = Alcotest . check t_header |
let hstr = [ ( " accept " , " application / xml " ) ; ( " transfer - encoding " , " chunked " ) ; ( " accept " , " text / html " ) ; ( " content - length " , " 100 " ) ; ] |
let prebuilt = H . of_list hstr |
let to_list_rev h = List . rev ( H . to_list h ) |
let to_list_tests ( ) = aessl " to_list ( init ( ) ) " [ ] H . ( to_list ( init ( ) ) ) ; aessl " to_list ( add ( init ( ) ) k v " [ ( " a " , " a1 " ) ] H . ( to_list ( add ( init ( ) ) " a " " a1 " ) ) ; aessl " to_list... |
let is_empty_tests ( ) = aeb " is_empty ( init ( ) ) " true H . ( is_empty ( init ( ) ) ) ; aeb " is_empty ( add ( init ( ) ) k v " false H . ( is_empty ( add ( init ( ) ) " a " " a1 " ) ) ; aeb " is_empty ( remove ( add ( init ( ) )... |
let init_with_tests ( ) = aessl " init_with k v " [ ( " traNsfer - eNcoding " , " chunked " ) ] H . ( to_list ( init_with " traNsfer - eNcoding " " chunked " ) ) |
let mem_tests ( ) = aeb " mem ( init ( ) ) k = false " false H . ( mem ( init ( ) ) " a " ) ; aeb " mem h k " true H . ( mem prebuilt " accept " ) ; aeb " mem h k " true H . ( mem prebuilt " content - length " ) ; aeb " mem h k " false H . ( ... |
let add_tests ( ) = aessl " add h k v " ( hstr @ [ ( " a " , " a1 " ) ] ) H . ( to_list ( add prebuilt " a " " a1 " ) ) ; aessl " add ( add h k v ) k v " ( hstr @ [ ( " a " , " a1 " ) ; ( " a " , " a1 " ) ] ) H . ( to... |
let get_tests ( ) = aeso " get ( add ( init ( ) k v ) k " ( Some " a1 " ) H . ( get ( add ( init ( ) ) " a " " a1 " ) " a " ) ; aeso " get ( add h k v ) k when mem h k = false " ( Some " a1 " ) H . ( get ( add prebuilt " a " " a1 " ... |
let add_list_tests ( ) = let l = [ ( " a " , " a1 " ) ; ( " b " , " b1 " ) ] in aessl " add_list ( init ( ) ) [ ] " [ ] H . ( to_list ( add_list ( init ( ) ) [ ] ) ) ; aessl " add_list ( init ( ) ) l " l H . ( to_list ( ... |
let add_multi_tests ( ) = let k , vals = ( " a " , [ " a1 " ; " a2 " ; " a3 " ] ) in let l = List . map ( fun v -> ( " a " , v ) ) vals in aessl " add_multi ( init ( ) ) k [ ] " [ ] H . ( to_list ( add_multi ( init ( ) ) k [ ] ... |
let add_unless_exists_tests ( ) = let k , v = ( " a " , " a1 " ) in let k ' , v ' = ( " transfer - encoding " , " chunked " ) in let k ' ' , v ' ' = ( " accept " , " text " ) /* in aessl " add_unless_exists ( init ( ) ) k v " [ ( k , ... |
let remove_tests ( ) = aessl " remove ( init ( ) ) k " [ ] H . ( to_list ( remove ( init ( ) ) " accept " ) ) ; aessl " remove ( add ( add ( init ( ) ) k v ) k v ) k " [ ] H . ( to_list ( remove ( add ( add ( init ( ) ) " k " " ... |
let replace_tests ( ) = let k , v , v ' = ( " a " , " a1 " , " a2 " ) in aessl " replace ( init ( ) ) k v " [ ( k , v ) ] H . ( to_list ( replace ( init ( ) ) k v ) ) ; aessl " replace ( add ( init ( ) ) k v ) k v " [ ( k , ... |
let h = H . init ( ) |> fun h -> H . add h " first " " 1 " |> fun h -> H . add h " second " " 2 " |> fun h -> H . add h " accept " " foo " |> fun h -> H . add h " accept " " bar " |
let update_tests ( ) = let h1 = H . update h " second " ( function Some _ -> Some " 2a " | None -> None ) in let h2 = H . replace h " second " " 2a " in aeh " update existing header " h1 h2 ; let h1 = H . update h " second " ( function Some _ -> None | None -> Som... |
let update_all_tests ( ) = let h1 = H . update_all h " second " ( function [ ] -> [ ] | _ -> [ " 2a " ] ) in let h2 = H . ( add ( remove h " second " ) " second " " 2a " ) in aeh " update_all existing header " h1 h2 ; let h1 = H . update_all h " se... |
let get_multi_tests ( ) = aesl " get_multi ( init ( ) ) k " [ ] H . ( get_multi ( init ( ) ) " a " ) ; aesl " get_multi h k when mem h k = false " [ ] H . ( get_multi prebuilt " a " ) ; aesl " get_multi h k when mem h k = true " [ " chunked " ] ... |
let hstr = [ ( " accept " , " application / xml " ) ; ( " transfer - encoding " , " chunked " ) ; ( " accept " , " text / html " ) ; ( " content - length " , " 100 " ) ; ] |
let get_multi_concat_tests ( ) = let h1 = H . ( add ( add prebuilt " a " " a1 " ) " a " " a2 " ) in aeso " get_multi_concat ( init ( ) ) k " None H . ( get_multi_concat ( init ( ) ) " a " ) ; aeso " get_multi_concat h k when mem h k = false " None H .... |
let map_tests ( ) = let a = " , a " in aessl " map ( fun _ v -> v ) ( init ( ) ) " [ ] H . ( to_list ( map ( fun _k v -> v ) ( init ( ) ) ) ) ; aessl " map ( fun _ v -> v ) ( init ( ) ) " ( H . to_list prebuilt ) H . ( to_list ( m... |
let fold_tests ( ) = let rev k v acc = H . ( add acc k v ) in let h1 = H . ( fold rev prebuilt ( init ( ) ) ) in aessl " [ fold ( fun k v acc -> H . ( add acc k v ) ) h ( init ( ) ) ] reverses the header " ( List . rev H . ( to_list h1 ) ) H . ( to_l... |
let iter_tests ( ) = let h = ref H . ( init ( ) ) in let rev k v = h := H . ( add ! h k v ) in H . ( iter rev prebuilt ) ; aessl " [ iter ( fun k v -> href := H . ( add ! href k v ) ) h ] reverses the header " ( List . rev H . ( to_list ! h ) ) H . ( ... |
let to_lines_tests ( ) = aesl " to_lines h " [ " accept : application / xml \ r \ n " ; " transfer - encoding : chunked \ r \ n " ; " accept : text / html \ r \ n " ; " content - length : 100 \ r \ n " ; ] H . ( to_lines prebuilt ) |
let to_frames_tests ( ) = aesl " to_frames h " [ " accept : application / xml " ; " transfer - encoding : chunked " ; " accept : text / html " ; " content - length : 100 " ; ] H . ( to_frames prebuilt ) |
let to_string_tests ( ) = aes " to_string h " " accept : application / xml \ r \ n \ transfer - encoding : chunked \ r \ n \ accept : text / html \ r \ n \ content - length : 100 \ r \ n \ \ r \ n " H . ( to_string prebuilt ) |
let many_headers ( ) = let size = 1000000 in let rec add_header num h = match num with | 0 -> h | n -> let k = Printf . sprintf " h % d " n in let v = Printf . sprintf " v % d " n in let h = H . add h k v in add_header ( num - 1 ) h in let h = add_header size ( H . init ( ) ... |
let transfer_encoding_tests ( ) = let h = H . of_list [ ( " transfer - encoding " , " gzip " ) ; ( " transfer - encoding " , " chunked " ) ] in let sh = H . to_string h in aes " transfer_encoding_string_is_ordered " sh " transfer - encoding : gzip \ r \ ntransfer... |
module HIO = Cohttp__Header_io . Make ( String_io . M ) |
let large_header ( ) = let sz = 1024 * 1024 * 100 in let h = H . init ( ) in let v1 = String . make sz ' a ' in let h = H . add h " x - large " v1 in let h = H . add h v1 " foo " in aeso " x - large " ( H . get h " x - large " ) ( Some v1 ) ; let obuf = Buf... |
let tests = ( " Unitary Header tests " , [ ( " Header . to_list " , ` Quick , to_list_tests ) ; ( " Header . is_empty " , ` Quick , is_empty_tests ) ; ( " Header . init_with " , ` Quick , init_with_tests ) ; ( " Header . mem " , ` Quick , me... |
let showdiff exp_str fnd_str = print_string ( " -- Expected --\ n " ^ exp_str ^ " \ n \ n -- Result --\ n " ^ fnd_str " ^\ n \ n " ) ; if not ( Debug . active " NO - VISUAL - DIFF " ) then match ( Debug . os ( ) ) with | " Darwin " -> ( let ( exp , exp_fd ... |
let log_test ( title : string ) ( to_s ' : a -> string ) ( result ' : a ) ( expected ' : a ) : unit = if result = expected then print_endline ( title " ^: Passed " ) else ( print_endline ( title " ^: Failed " ) ; showdiff ( to_s expected ) ( to_s result ) ; ... |
let log_boolean ( title : string ) ( result : bool ) ( expected : bool ) : unit = log_test title ( function true -> " TRUE " | false -> " FALSE " ) result expected ; ; |
let log_list_test ( title : string ) ( to_s ' : a -> string ) ( result ' : a list ) ( expected ' : a list ) : unit = if result = expected then print_endline ( title " ^: Passed " ) else ( let rec diff_lists rlist elist = let recurse rstr estr new_rlist new_elist = let ( new_... |
let log_collection_test ( title : string ) ( result : Values . K3Value . t ) ( expected ( : Values . K3Value . t list * Values . K3Value . t ) list ) : unit = let collection_entries = match result with | Values . K3Value . SingleMap ( m ) -> Values . K3ValuationMap . to_... |
let parse_sql_expr ( expr : string ) : Sql . expr_t = try Sqlparser . expression Sqllexer . tokenize ( Lexing . from_string expr ) with Parsing . Parse_error -> ( print_endline ( " Error parsing ' " :^ expr " ' " ) ; ^ let _ = Parsing . set_trace true in Sqlparser . exp... |
let parse_calc ( ? opt = false ) ( expr : string ) : Calculus . expr_t = try let ret = Calculusparser . calculusExpr Calculuslexer . tokenize ( Lexing . from_string expr ) in if opt then CalculusTransforms . optimize_expr ( Calculus . schema_of_expr ret ) ret else ret with Parsing . ... |
let parse_stmt ( m3_stmt : string ) = try Calculusparser . mapTriggerStmt Calculuslexer . tokenize ( Lexing . from_string m3_stmt ) with Parsing . Parse_error -> ( print_endline ( " Error parsing ' " :^ m3_stmt " ' " ) ; ^ let _ = Parsing . set_trace true in Calculusparser .... |
let k3_map ( decl : string ) : K3 . map_t = try K3parser . mapDeclaration K3lexer . tokenize ( Lexing . from_string ( decl " ; " ) ) ^ with Parsing . Parse_error -> ( print_endline ( " Error parsing ' " :^ decl " ; ' " ) ; ^ let _ = Parsing . set_trace true i... |
let parse_k3 ( expr : string ) : K3 . expr_t = try K3parser . statement K3lexer . tokenize ( Lexing . from_string expr ) with Parsing . Parse_error -> ( print_endline ( " Error parsing ' " :^ expr " ' " ) ; ^ let _ = Parsing . set_trace true in K3parser . statement K3le... |
let var v = ( v , Type . TFloat ) ; ; |
let rel rn rv = ( Calculus . Rel ( rn , List . map var rv ) ) ; ; |
let schema_rel ( reln : string ) ( relv : string list ) = ( reln , List . map var relv , Schema . StreamRel ) ; ; |
let event ins reln relv = ( ( if ins then Schema . InsertEvent ( schema_rel reln relv ) else Schema . DeleteEvent ( schema_rel reln relv ) ) ) ; ; |
let mk_db rels = ( let ret_db = Schema . empty_db ( ) in List . iter ( fun ( reln , relv ) -> Schema . add_rel ret_db ( schema_rel reln relv ) ) rels ; ret_db ) ; ; |
let mk_float_collection elems = List . map ( fun ( k , v ) -> ( List . map ( fun x -> Values . K3Value . BaseValue ( CFloat ( x ) ) ) k , Values . K3Value . BaseValue ( CFloat ( v ) ) ) ) elems |
let compile ( db : Schema . t ) ( name : string ) ( expr : string ) = Compiler . compile db [ ( name , parse_calc expr ) ] ; ; |
module Make ( M : Ndarray_Algodiff with type elt = float ) = struct module AlgoM = Owl_algodiff_generic . Make ( M ) open AlgoM let eps = 1e - 14 let approx_equal a b = Stdlib . abs_float ( a . - b ) < eps let approx_equal_arr ( ? eps = eps ) a b = let r = ref true in M . ( sub ... |
let approx_equal ( ? eps = 1e - 12 ) a b = Stdlib . abs_float ( a . - b ) < eps |
module Make ( M : Ndarray_Algodiff with type elt = float ) = struct module AlgoM = Owl_algodiff_generic . Make ( M ) open AlgoM module To_test = struct let check_grad ( ? eps = 1e - 6 ) f dfs xys = let dim = Array . length xys in let xys_arr = M . init [ | 1 ; dim ] | ( fun i ... |
module Make ( M : Ndarray_Algodiff with type elt = float ) = struct module M = Owl . Mat module AlgoM = Owl . Algodiff . D open AlgoM let ( ) = Owl_stats_prng . init 0 let n = 3 let n_samples = 20 let threshold = 1E - 6 let eps = 1E - 5 module FD = Owl_algodiff_check . Make ( Alg... |
object end M . cl [ ' a , ' b ] M . cl object ( ' ty ) inherit cl val mutable virtual var : bool method private bar1 x ~ y : bool method private virtual bar2 : ' a ' b . ( ' a , ' b ) Hashtbl . t constraint ' a = ' b end [ ' a , ' b ] M . cl fun a b -> object ... |
let e = var <- true |
let e = { < var = false ; var2 = true ; } > object val x = true end and virtual [ ' a , ' b ] cl2 x y : object val x : bool end = fun x y -> object val x : bool = true end : object end method x : int end < > |
let ( ) = ( ) < . . > |
let ( ) = ( ) < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t > |
let ( ) = ( ) < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t ; . . > |
let ( ) = ( ) # M . meth ' a # M . meth ( ' a , ' b ' * c ) # M . meth |
type a = < > |
type a = < . . > |
type a = < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t > |
type a = < meth : int option ; meth2 : ' a . ' a option ; meth3 : ' a ' b . ( ' a , ' b ) Hashtbl . t ; . . > |
type t = < a : int ; b : < a : int ; b : < c : int > > > |
type t = < a : int ; b : < a : int ; b : < c : int -> int > ; > c : int > |
type ' a t = | Bla : < x : int > t | Blo : < y : int > t |
module Make ( N : Ndarray_Algodiff with type elt = float ) = struct let tolerance_f64 = 1e - 8 let tolerance_f32 = 5e - 4 let close a b = N . ( sub a b |> abs |> sum ' ) < tolerance_f32 let test_conv2d input_shape kernel_shape stride pad = let inp = N . sequential ~ a : 1 . input_sha... |
module Make ( N : Ndarray_Algodiff with type elt = float ) = struct let tolerance_f64 = 1e - 8 let tolerance_f32 = 5e - 4 let close a b = N . ( sub a b |> abs |> sum ' ) < tolerance_f32 let test_conv3d input_shape kernel_shape stride pad = let ts1 = Array . fold_left ( * ) 1 input_s... |
module type CONV_IMPL = sig val owl_spatial_conv : ( ' a , ' b ) Owl_dense_ndarray_generic . kind -> ( ' a , ' b ) Owl_core_types . owl_arr_op22 val owl_spatial_conv_backward_input : ( ' a , ' b ) Owl_dense_ndarray_generic . kind -> ( ' a , ' b ) Owl_core_types . owl... |
module MEC = struct let owl_spatial_conv = Owl_ndarray_conv . _owl_spatial_conv_mec let owl_spatial_conv_backward_input = Owl_ndarray_conv . _owl_spatial_conv_backward_input_mec let owl_spatial_conv_backward_kernel = Owl_ndarray_conv . _owl_spatial_conv_backward_kernel_mec let owl_cuboid_conv = Owl_ndarra... |
module NAIVE = struct let owl_spatial_conv = Owl_ndarray_conv . _owl_spatial_conv_naive let owl_spatial_conv_backward_input = Owl_ndarray_conv . _owl_spatial_conv_backward_input_naive let owl_spatial_conv_backward_kernel = Owl_ndarray_conv . _owl_spatial_conv_backward_kernel_naive let owl_cuboid_conv = Ow... |
module Make ( I : CONV_IMPL ) = struct include N let conv2d ( ? padding = SAME ) input kernel stride = let input_shp = shape input in let batches = input_shp . ( 0 ) in let input_cols = input_shp . ( 1 ) in let input_rows = input_shp . ( 2 ) in let in_channel = input_shp . ( 3... |
module TEST_MEC = Make ( MEC ) |
module Conv2D_MEC = Unit_conv2d_generic . Make ( TEST_MEC ) |
module Conv3D_MEC = Unit_conv3d_generic . Make ( TEST_MEC ) |
module TEST_NAIVE = Make ( NAIVE ) |
module Conv2D_NAIVE = Unit_conv2d_generic . Make ( TEST_NAIVE ) |
module Conv3D_NAIVE = Unit_conv3d_generic . Make ( TEST_NAIVE ) |
let matrix = Alcotest . testable Owl_pretty . pp_dsnda M . equal |
let x0 = M . zeros Float64 3 4 |
let x1 = M . ones Float64 3 4 |
let x2 = M . sequential Float64 3 4 |
module To_test = struct let sequential ( ) = M . sequential Float64 3 4 let row_num x = M . row_num x let col_num x = M . col_num x let numel x = M . numel x let fill ( ) = let x = M . empty Float64 3 4 in M . fill x 1 . ; x let get x = M . get x 1 2 let set ( ) = let x = ... |
let sequential ( ) = Alcotest . ( check matrix ) " sequential " x2 ( To_test . sequential ( ) ) |
let row_num ( ) = Alcotest . ( check int ) " row_num " 3 ( To_test . row_num x2 ) |
let col_num ( ) = Alcotest . ( check int ) " col_num " 4 ( To_test . col_num x0 ) |
let numel ( ) = Alcotest . ( check int ) " numel " 12 ( To_test . numel x0 ) |
let get ( ) = Alcotest . ( check ( float eps ) ) " get " 6 . ( To_test . get x2 ) |
let set ( ) = Alcotest . ( check ( float eps ) ) " set " 5 . ( To_test . set ( ) ) |
let fill ( ) = Alcotest . ( check matrix ) " fill " x1 ( To_test . fill ( ) ) |
let row0 ( ) = Alcotest . ( check bool ) " row0 " true ( To_test . row0 ( ) ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.