From 862aadbd6bc709659b1b873bff02fbaeff97b69c Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Fri, 31 Oct 2008 17:42:42 +0100 Subject: [PATCH] packages for unittests moved to packages file. Or should these be moved to a separate UT packages file? --- src/packages.lisp | 87 ++++++++++++++++++++++++++++++++- src/unittests/unittests-arrays.lisp | 33 ------------- src/unittests/unittests-data-clos.lisp | 12 +---- src/unittests/unittests-lstypes.lisp | 13 +---- src/unittests/unittests-proto.lisp | 16 ------ src/unittests/unittests-regression.lisp | 52 ++++++-------------- src/unittests/unittests.lisp | 26 ++-------- 7 files changed, 107 insertions(+), 132 deletions(-) diff --git a/src/packages.lisp b/src/packages.lisp index 9dd7d0d..a261264 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -1,6 +1,6 @@ ;;; -*- mode: lisp -*- -;;; Time-stamp: <2008-10-04 15:34:06 tony> +;;; Time-stamp: <2008-10-31 17:40:19 tony> ;;; Creation: <2008-03-11 19:18:34 user> ;;; File: packages.lisp ;;; Author: AJ Rossini @@ -474,3 +474,88 @@ done for a user- or analysis-package.") <= float imagpart)) +(defpackage :lisp-stat-data-examples + (:documentation "Example data used for unittests and illustrations,") + (:use :common-lisp + :lisp-stat) + (:export iron aluminum diabetes )) + +;;; + +(defpackage :lisp-stat-unittests + (:use :common-lisp :lift :lisp-stat) + (:shadowing-import-from :lisp-stat + slot-value call-method call-next-method ;; objects + expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath + asin acos atan sinh cosh tanh asinh acosh atanh float random + truncate floor ceiling round minusp zerop plusp evenp oddp + < <= = /= >= > ;; complex + conjugate realpart imagpart phase + min max logand logior logxor lognot ffloor fceiling + ftruncate fround signum cis) + (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec + almost= almost=lists numerical=)) ; compare + +(defpackage :lisp-stat-unittests-arrays + (:use :common-lisp :lift + ;; use feature tests to check for matrix packages, i.e. + #+matlisp :matlisp + #+clem :clem + :lisp-matrix + ;; and likewise, handle the tests appropriately as well. + :lisp-stat ;; basic tools + :lisp-stat-unittests) ;; support + (:shadowing-import-from :lisp-stat + ;; objects + slot-value call-method call-next-method + + ;; lsmath + expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan + asin acos atan sinh cosh tanh asinh acosh atanh float random + truncate floor ceiling round minusp zerop plusp evenp oddp + < <= = /= >= > + min max logand logior logxor lognot ffloor fceiling + ftruncate fround signum cis + + ;; complex + conjugate realpart imagpart phase + + ;; matlisp + fft transpose) + (:shadowing-import-from :matlisp + real ;; common-lisp + ) + (:export run-lisp-stat-tests run-lisp-stat-test scoreboard)) + + +(defpackage :lisp-stat-types-unittests + (:use :common-lisp + :lift :lisp-stat-unittests + :lisp-stat-types)) + +(defpackage :lisp-stat-data-clos-example + (:use :common-lisp + :lift :lisp-stat-unittests + :lisp-stat-data-clos)) + +(defpackage :lisp-stat-unittests-proto + (:use :common-lisp :lift :lisp-stat :lisp-stat-unittests) + (:shadowing-import-from :lisp-stat + slot-value call-method call-next-method ;; objects + expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath + asin acos atan sinh cosh tanh asinh acosh atanh float random + truncate floor ceiling round minusp zerop plusp evenp oddp + < <= = /= >= > ;; complex + conjugate realpart imagpart phase + min max logand logior logxor lognot ffloor fceiling + ftruncate fround signum cis) + (:export lisp-stat-ut-proto)) ;; unit tests -- rename? + + +(defpackage :lisp-stat-regression-unittests + (:use :common-lisp + :lift + :lisp-stat + :lisp-stat-data-examples + :lisp-stat-unittests)) + diff --git a/src/unittests/unittests-arrays.lisp b/src/unittests/unittests-arrays.lisp index 0759278..8df6b2f 100644 --- a/src/unittests/unittests-arrays.lisp +++ b/src/unittests/unittests-arrays.lisp @@ -8,39 +8,6 @@ ;;; tests. However, where they will end up is still to be ;;; determined. -(in-package :cl-user) - -(defpackage :lisp-stat-unittests-arrays - (:use :common-lisp :lift - ;; use feature tests to check for matrix packages, i.e. - #+matlisp :matlisp - #+clem :clem - ;; and likewise, handle the tests appropriately as well. - :lisp-stat ;; basic tools - :lisp-stat-unittests) ;; support - (:shadowing-import-from :lisp-stat - ;; objects - slot-value call-method call-next-method - - ;; lsmath - expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan - asin acos atan sinh cosh tanh asinh acosh atanh float random - truncate floor ceiling round minusp zerop plusp evenp oddp - < <= = /= >= > - min max logand logior logxor lognot ffloor fceiling - ftruncate fround signum cis - - ;; complex - conjugate realpart imagpart phase - - ;; matlisp - fft transpose) - (:shadowing-import-from :matlisp - real ;; common-lisp - ) - (:export run-lisp-stat-tests run-lisp-stat-test scoreboard)) - - (in-package :lisp-stat-unittests-arrays) ;;; TEST for Arrays and Linear Algebra. diff --git a/src/unittests/unittests-data-clos.lisp b/src/unittests/unittests-data-clos.lisp index c631e25..44cf9aa 100644 --- a/src/unittests/unittests-data-clos.lisp +++ b/src/unittests/unittests-data-clos.lisp @@ -5,7 +5,7 @@ ;;; Copyright: (c)2008, AJ Rossini. BSD, LLGPL, or GPLv2, depending ;;; on how it arrives. ;;; Purpose: unittests for the data-clos package -;;; Time-stamp: <2008-05-09 14:18:19 tony> +;;; Time-stamp: <2008-10-31 17:40:01 tony> ;;; Creation: <2008-05-09 14:18:19 tony> ;;; What is this talk of 'release'? Klingons do not make software @@ -15,16 +15,6 @@ ;;; This organization and structure is new to the 21st Century ;;; version. -(in-package :cl-user) - -;; if needed, but need to set the ASDf path first...! -;; (asdf:oos 'asdf:load-op :lift) - -(defpackage :lisp-stat-data-clos-example - (:use :common-lisp - :lift :lisp-stat-unittests - :lisp-stat-data-clos)) - (in-package :lisp-stat-data-clos-example) ;;; diff --git a/src/unittests/unittests-lstypes.lisp b/src/unittests/unittests-lstypes.lisp index a31f3e8..7b8be84 100644 --- a/src/unittests/unittests-lstypes.lisp +++ b/src/unittests/unittests-lstypes.lisp @@ -5,7 +5,7 @@ ;;; Copyright: (c)2008, AJ Rossini. ;;; License: BSD, see LICENSE.BSD file for details. ;;; Purpose: unit-tests for lispstat typing. -;;; Time-stamp: <2008-05-28 08:25:28 tony> +;;; Time-stamp: <2008-10-31 17:39:42 tony> ;;; Creation: <2008-05-09 14:16:56 tony> ;;; What is this talk of 'release'? Klingons do not make software @@ -15,19 +15,8 @@ ;;; This organization and structure is new to the 21st Century ;;; version. -(in-package :cl-user) - -;; if needed, but need to set the ASDf path first...! -;; (asdf:oos 'asdf:load-op :lift) - -(defpackage :lisp-stat-types-unittests - (:use :common-lisp - :lift :lisp-stat-unittests - :lisp-stat-types)) - (in-package :lisp-stat-types-unittests) - (deftestsuite lisp-stat-ut-types (lisp-stat-ut) ()) (addtest (lisp-stat-ut-types) check-one-nonneg-fixnum1 diff --git a/src/unittests/unittests-proto.lisp b/src/unittests/unittests-proto.lisp index 353cc38..99ceefb 100644 --- a/src/unittests/unittests-proto.lisp +++ b/src/unittests/unittests-proto.lisp @@ -8,27 +8,11 @@ ;;; tests. However, where they will end up is still to be ;;; determined. -(in-package :cl-user) - -(defpackage :lisp-stat-unittests-proto - (:use :common-lisp :lift :lisp-stat :lisp-stat-unittests) - (:shadowing-import-from :lisp-stat - slot-value call-method call-next-method ;; objects - expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath - asin acos atan sinh cosh tanh asinh acosh atanh float random - truncate floor ceiling round minusp zerop plusp evenp oddp - < <= = /= >= > ;; complex - conjugate realpart imagpart phase - min max logand logior logxor lognot ffloor fceiling - ftruncate fround signum cis) - (:export lisp-stat-ut-proto)) ;; unit tests -- rename? (in-package :lisp-stat-unittests-proto) ;;; Object System tests -(deftestsuite lisp-stat-proto (lisp-stat) ()) - ;; need to ensure stability of add, display, send, instantiate and ;; similar actions. diff --git a/src/unittests/unittests-regression.lisp b/src/unittests/unittests-regression.lisp index 47d5d1c..1112ac3 100644 --- a/src/unittests/unittests-regression.lisp +++ b/src/unittests/unittests-regression.lisp @@ -5,7 +5,7 @@ ;;; Copyright: (c)2008, AJ Rossini. ;;; License: BSD, see LICENSE.BSD file for details. ;;; Purpose: unit-tests for regression; also make good examples -;;; Time-stamp: <2008-05-13 17:16:07 tony> +;;; Time-stamp: <2008-10-31 17:33:20 tony> ;;; Creation: <2008-05-13 17:16:07 tony> ;;; What is this talk of 'release'? Klingons do not make software @@ -15,52 +15,30 @@ ;;; This organization and structure is new to the 21st Century ;;; version. -(in-package :cl-user) - +;; (in-package :cl-user) ;; if needed, but need to set the ASDf path first...! ;; (asdf:oos 'asdf:load-op :lift) -(defpackage :lisp-stat-regression-unittests - (:use :common-lisp - :lift :lisp-stat-unittests - :lisp-stat-types)) - (in-package :lisp-stat-regression-unittests) -(defun run-lisp-stat-tests () - (run-tests :suite 'lisp-stat)) - -(defun run-lisp-stat-test (&rest x) - (run-test x)) - (deftestsuite lisp-stat-regression (lisp-stat) ()) +;;; TESTS -;;; setup data tht we need to get this work done. - -(defvar regr-testdata nil - "dataset used for testing") - -(defvar regr-testdata-iron nil "testvector one") -(defvar regr-testdata-alu nil "testvector one") -(defvar regr-testdata-othe nil "testvector one") -(defvar m1 nil "fitted regr model 1") -(defvar m1 nil "fitted regr model 2") - - -;;; now go to the tests so that we can do the right thing with the -;;; eval. +(addtest (lisp-stat-regression) + lin-regr1-fit-basis + (let ((m1 (regression-model iron aluminum :print nil))) + (ensure (> 0 (send m1 :basis))))) -(addtest (lisp-stat-regression) simp-lin-regr1-fit - (ensure - (progn - (setf m1 (regression-model regr-testdat-iron regr-testdat-alu)) - (equal (list ...) - (send m1 :coefs))))) +(addtest (lisp-stat-regression) + lin-regr2-fit-basis + (let ((m1 (regression-model (list iron aluminum) absorbtion :print nil))) + (ensure (> 0 (send m1 :basis))))) -(addtest (lisp-stat-regression) lin-regr1-bomb - (ensure-error - (check-nonneg-fixnum -3))) +(addtest (lisp-stat-regression) + check-nonneg-fixnum + (ensure-error + (check-nonneg-fixnum -3))) ;;; ;; (run-tests) diff --git a/src/unittests/unittests.lisp b/src/unittests/unittests.lisp index abd6432..28a917f 100644 --- a/src/unittests/unittests.lisp +++ b/src/unittests/unittests.lisp @@ -8,22 +8,6 @@ ;;; tests. However, where they will end up is still to be ;;; determined. -(in-package :cl-user) - -(defpackage :lisp-stat-unittests - (:use :common-lisp :lift :lisp-stat) - (:shadowing-import-from :lisp-stat - slot-value call-method call-next-method ;; objects - expt + - * / ** mod rem abs 1+ 1- log exp sqrt sin cos tan ;; lsmath - asin acos atan sinh cosh tanh asinh acosh atanh float random - truncate floor ceiling round minusp zerop plusp evenp oddp - < <= = /= >= > ;; complex - conjugate realpart imagpart phase - min max logand logior logxor lognot ffloor fceiling - ftruncate fround signum cis) - (:export run-lisp-stat-tests run-lisp-stat-test scoreboard ; exec - almost= almost=lists numerical=)) ; compare - (in-package :lisp-stat-unittests) ;;; TESTS @@ -37,12 +21,12 @@ (defun run-lisp-stat-test (&rest x) (run-test x)) - (deftestsuite lisp-stat-ut () ()) -(deftestsuite lisp-stat-ut-lin-alg (lisp-stat-ut) ()) -(deftestsuite lisp-stat-ut-spec-fns (lisp-stat-ut) ()) -(deftestsuite lisp-stat-ut-probdistn (lisp-stat-ut) ()) +;; others should be defined in another place...: +;;(deftestsuite lisp-stat-ut-lin-alg (lisp-stat-ut) ()) +;;(deftestsuite lisp-stat-ut-spec-fns (lisp-stat-ut) ()) +;;(deftestsuite lisp-stat-ut-probdistn (lisp-stat-ut) ()) (defun almost= (a b &key (tol 0.000001)) "Numerically compares 2 values to a tolerance." @@ -55,8 +39,6 @@ (and (almost= (car a) (car b) :tol tol) (almost=lists (cdr a) (cdr b) :tol tol)))) - - ;; Need to consider a CLOSy approach for almost= to cover the range of ;; possible data structures that we would like to be equal to a ;; particular tolerance range. For example, fill in a shell like: -- 2.11.4.GIT