Skip to content

Commit

Permalink
Re-enable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rleonid committed Aug 31, 2016
1 parent 9f5dab8 commit 26b7cb7
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 43 deletions.
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ LITE_BUILD_DIR=_lite_build
PACKAGES=lacaml lbfgs ocephes
PACKAGES_TEST=$(PACKAGES) kaputt dsfo
PACKAGES_COVERED:=$(PACKAGES_TEST) bisect_ppx
PACKAGES_INSTALL=cppo $(PACKAGES)
PACKAGES_INSTALL_TEST=cppo $(PACKAGES_COVERED)
CPPO_TAG:=-plugin-tag 'package(cppo_ocamlbuild)'
PACKAGES_INSTALL=$(PACKAGES)
PACKAGES_INSTALL_TEST=$(PACKAGES_COVERED)

SOURCE_DIRS=util unc stats cls rgr uns
INSTALL_EXTS=a o cma cmi cmo cmt cmx cmxa cmxs
Expand All @@ -17,7 +16,7 @@ default: FORCE
@echo "available targets:"
@echo " build compiles Oml"
@echo " lite compiles only Oml_lite"
@echo " tests runs unit tests"
@echo " test runs unit tests"
@echo " doc generates ocamldoc documentations"
@echo " clean deletes all produced files"
@echo " setup opam install Oml dependencies"
Expand Down Expand Up @@ -58,16 +57,14 @@ clean:

omltest.native:
ocamlbuild -build-dir $(TEST_BUILD_DIR) \
$(CPPO_TAG) \
-use-ocamlfind $(foreach package, $(PACKAGES_TEST),-package $(package)) \
-I src/lib $(foreach sd, $(SOURCE_DIRS), -I src/lib$(sd)) -I src/test omltest.native
$(foreach sd, $(SOURCE_DIRS), -I src/lib$(sd)) -I src/lib -I src/test omltest.native

test: omltest.native
time ./omltest.native ${TEST}

covered_test.native:
ocamlbuild -build-dir $(TEST_BUILD_DIR) \
$(CPPO_TAG) \
-use-ocamlfind $(foreach package, $(PACKAGES_COVERED),-package $(package)) \
-I src/lib $(foreach sd, $(SOURCE_DIRS), -I src/lib$(sd)) -I src/test omltest.native

Expand Down
57 changes: 51 additions & 6 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,47 @@ let add_ml_and_mlt_and_depends () =
]
end

(* For unknown reasons this rule is not firing?
Or maybe it is insufficient to trigger the generation of a
full module needed for test. Using this would prevent
the need for stub code such as functions.ml.
let add_lite_ml_and_mlt_and_depends () =
let dmlt = "%.mlt" in
let doml = "oml_%.ml" in
let domll = "oml_lite_%.ml" in
let pmld = "%.ml.depends" in
let pmlj = "%.mlj" in
let pmljd = "%.mlj.depends" in
rule "concat oml_ and oml_lite_ prefixed ml and mlt files, and build dependencies"
~insert:`top
~deps:[ dmlt; doml; domll ]
~prods:[ pmld; pmlj; pmljd ]
begin fun env _build ->
let mlt = env dmlt in
let oml = env doml in
let omll = env domll in
let mlj = env pmlj in
let ml_depends = env pmld in
let mlj_depends = env pmljd in
let ocamldep_tags =
(Tags.union (tags_of_pathname oml) (tags_of_pathname omll))
++ "ocaml" ++ "ocamldep"
in
Seq [ Cmd ( S [ A "cat"; P omll; Sh ">"; P mlj])
; Cmd ( S [ A "cat"; P oml; Sh ">>"; P mlj])
; Cmd ( S [ A "echo"; A (sprintf "# 0 %S" mlt); Sh ">>"; P mlj])
; Cmd ( S [ A "echo"; A "(*BISECT-IGNORE-BEGIN*)"; Sh ">>"; P mlj])
; Cmd ( S [ A "cat"; P mlt; Sh ">>"; P mlj])
; Cmd ( S [ A "echo"; A "(*BISECT-IGNORE-END*)"; Sh ">>"; P mlj])
(* Now build the dependencies for the mlj file. *)
; Cmd ( S [ A "ocamlfind"; A "ocamldep"; T ocamldep_tags ; A "-ml-synonym"
; Sh "'.mlj'"; A "-modules"; P mlj; Sh ">"; P mlj_depends])
(* Fake the ml.depends to be the same as mlj.depends. *)
; Cmd ( S [ A "sed"; A "-E"; A "s/mlj/ml/g"; P mlj_depends;
Sh ">" ; P ml_depends])
]
end *)

let report_dependencies pth =
let () = printf "here are the %s dependencies\n" pth in
List.iter (function | `just_try, s -> printf "just_try: %s\n" s
Expand Down Expand Up @@ -105,18 +146,22 @@ let () =
| Before_rules -> ()
| After_rules ->
begin
Pathname.define_context "src/lib/" ["src/lib/util"];
Pathname.define_context "src/lib/unc" ["src/lib/util"; "src/lib/unc"];
Pathname.define_context "src/lib/stats" ["src/lib/util"; "src/lib/unc"; "src/lib/stats"];
Pathname.define_context "src/lib/cls" ["src/lib/util"; "src/lib/unc"; "src/lib/stats"; "src/lib/cls"];
Pathname.define_context "src/lib/rgr" ["src/lib/util"; "src/lib/unc"; "src/lib/stats"; "src/lib/rgr"];
Pathname.define_context "src/lib/uns" ["src/lib/util"; "src/lib/unc"; "src/lib/uns"];

if is_test_target () then begin
add_ml_and_mlt_and_depends ();
(*add_lite_ml_and_mlt_and_depends (); *)
add_compile_mlj_to_native_rule ();
add_compile_mlj_to_byte_rule ();
Options.make_links := true;
Pathname.define_context "src/test"
[ "src/lib"; "src/lib/util"; "src/lib/unc"; "src/lib/stats"
; "src/lib/cls"; "src/lib/rgr"; "src/lib/uns"];
Pathname.define_context "src/lib" ["src/lib/util"; "src/lib/stats"];
Pathname.define_context "src/lib/unc" ["src/lib/util"; "src/lib/stats"];
Pathname.define_context "src/lib/stats" ["src/lib/util"; ];
Pathname.define_context "src/lib/cls" ["src/lib/util"; "src/lib/stats"];
Pathname.define_context "src/lib/rgr" ["src/lib/util"; "src/lib/unc"; "src/lib/stats"];
Pathname.define_context "src/lib/uns" ["src/lib/util"; "src/lib/unc" ];
end;

(* To build without interfaces
Expand Down
22 changes: 22 additions & 0 deletions src/lib/cls/naive_bayes.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(*
Copyright 2016
Leonid Rozenberg <leonidr@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)

(** See message above add_lite_ml_and_mlt_and_depends for explanation. *)
if Filename.basename Sys.argv.(0) <> "omltest.native" then
failwith ("Linked the Functions tests stub file into: " ^ Sys.argv.(0))

include Oml_naive_bayes
1 change: 1 addition & 0 deletions src/lib/cls/naive_bayes.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

open Test_utils
module P = Probabilities
module List = ListLabels

let () =
let add_simple_test = Test.add_simple_test_group "Naive Bayes" in
Expand Down
5 changes: 2 additions & 3 deletions src/lib/online.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

open Test_utils
open Util
module D = Statistics.Descriptive
module D = Descriptive

(* In order for these tests to work well, we have to span the range of
acceptable floats as well. If we're uniformly sampling from [0, largest_float]
we'll have different characteristics if largest_float is tiny or huge:
this will influence the significand in the algorithms.
*)
this will influence the significand in the algorithms. *)

let () =
let add_random_test
Expand Down
4 changes: 2 additions & 2 deletions src/lib/rgr/multivariate.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ open Test_utils

open Util

module Descriptive = Statistics.Descriptive
module Vectors = Uncategorized.Vectors
module Descriptive = Descriptive
module Vectors = Vectors

let looe_manually lambda pred resp =
let predi = Array.to_list pred |> List.mapi (fun i p -> (i, p)) in
Expand Down
2 changes: 1 addition & 1 deletion src/lib/rgr/tikhonov.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
open Test_utils
open Util

module Matrices = Uncategorized.Matrices
module Matrices = Matrices

let () =
let add_random_test
Expand Down
22 changes: 22 additions & 0 deletions src/lib/rgr/univariate.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(*
Copyright 2016
Leonid Rozenberg <leonidr@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)

(** See message above add_lite_ml_and_mlt_and_depends for explanation. *)
if Filename.basename Sys.argv.(0) <> "omltest.native" then
failwith ("Linked the Functions tests stub file into: " ^ Sys.argv.(0))

include Oml_univariate
22 changes: 22 additions & 0 deletions src/lib/stats/functions.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(*
Copyright 2016
Leonid Rozenberg <leonidr@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)

(** See message above add_lite_ml_and_mlt_and_depends for explanation. *)
if Filename.basename Sys.argv.(0) <> "omltest.native" then
failwith ("Linked the Functions tests stub file into: " ^ Sys.argv.(0))

include Oml_functions
2 changes: 1 addition & 1 deletion src/lib/unc/estimations.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*)
open Test_utils
open Util
module D = Statistics.Descriptive
module D = Descriptive

let () =
let add_random_test
Expand Down
3 changes: 1 addition & 2 deletions src/lib/uns/pca.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*)

open Lacaml.D

open Uncategorized.Lacaml_util
open Lacaml_util

type t = { variances : vec
; components : mat
Expand Down
1 change: 0 additions & 1 deletion src/lib/uns/pca.mlt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
open Test_utils
open Util
open Lacaml.D
module Matrices = Uncategorized.Matrices

let () =
let matrix_size = 100 in
Expand Down
40 changes: 20 additions & 20 deletions src/test/omltest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ open Test_utils
module Rank = Rank
module Util = Util

module Estimations = Uncategorized.Estimations
module Solvers = Uncategorized.Solvers
module Svd = Uncategorized.Svd

module Matrices = Uncategorized.Matrices
module Vectors = Uncategorized.Vectors

module Functions = Statistics.Functions
module Descriptive = Statistics.Descriptive
module Distributions = Statistics.Distributions
module Hypothesis_test = Statistics.Hypothesis_test
module Measures = Statistics.Measures
module Sampling = Statistics.Sampling

module Estimations = Estimations
module Solvers = Solvers
module Svd = Svd

module Matrices = Matrices
module Vectors = Vectors

module Functions = Functions
module Descriptive = Descriptive
module Distributions = Distributions
module Hypothesis_test = Hypothesis_test
module Measures = Measures
module Sampling = Sampling
module Online = Online

module Naive_bayes = Classification.Naive_bayes
module Logistic_regression = Classification.Logistic_regression

module Univariate = Regression.Univariate
module Multivariate = Regression.Multivariate
module Tikhonov = Regression.Tikhonov
module Interpolate = Regression.Interpolate
module Naive_bayes = Naive_bayes
module Logistic_regression = Logistic_regression

module Univariate = Univariate
module Multivariate = Multivariate
module Tikhonov = Tikhonov
module Interpolate = Interpolate

module Pca = Pca

Expand Down

0 comments on commit 26b7cb7

Please sign in to comment.