3 ;;; Time-stamp: <2009-07-06 18:38:42 tony>
4 ;;; Creation: <2008-09-08 08:06:30 tony>
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c) 2007-2008, AJ Rossini <blindglobe@gmail.com>. BSD.
8 ;;; Purpose: Stuff that needs to be made working sits inside the
9 ;;; progns... This file contains the current challenges to
10 ;;; solve, including a description of the setup and the work
13 ;;; What is this talk of 'release'? Klingons do not make software
14 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
15 ;;; designers and quality assurance people in its wake.
22 (asdf:oos
'asdf
:load-op
'lispstat
))
24 (defun init-CLS-graphics ()
26 (asdf:oos
'asdf
:load-op
'cl-cairo2-x11
)
27 (asdf:oos
'asdf
:load-op
'cl-2d
))
31 ;;(asdf:oos 'asdf:load-op 'lisp-matrix)
32 ;;(asdf:oos 'asdf:compile-op 'lispstat :force t)
33 ;;(asdf:oos 'asdf:load-op 'lispstat)
35 (in-package :lisp-stat-unittests
)
37 ;; tests = 80, failures = 8, errors = 15
38 (run-tests :suite
'lisp-stat-ut
)
39 (describe (run-tests :suite
'lisp-stat-ut
))
41 (describe 'lisp-stat-ut
)
42 (documentation 'lisp-stat-ut
'type
)
44 ;; FIXME: Example: currently not relevant, yet
45 ;; (describe (lift::run-test :test-case 'lisp-stat-unittests::create-proto
46 ;; :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
48 (describe (lift::run-tests
:suite
'lisp-stat-ut-dataframe
))
49 (lift::run-tests
:suite
'lisp-stat-ut-dataframe
)
51 (describe (lift::run-test
52 :test-case
'lisp-stat-unittests
::create-proto
53 :suite
'lisp-stat-unittests
::lisp-stat-ut-proto
))
60 ;; REVIEW: general Lisp use guidance
62 (fdefinition 'make-matrix
)
63 (documentation 'make-matrix
'function
)
65 #| Examples from CLHS
, a bit of guidance.
67 ;; This function assumes its callers have checked the types of the
68 ;; arguments, and authorizes the compiler to build in that assumption.
69 (defun discriminant (a b c
)
70 (declare (number a b c
))
71 "Compute the discriminant for a quadratic equation."
72 (- (* b b
) (* 4 a c
))) => DISCRIMINANT
73 (discriminant 1 2/3 -
2) => 76/9
75 ;; This function assumes its callers have not checked the types of the
76 ;; arguments, and performs explicit type checks before making any assumptions.
77 (defun careful-discriminant (a b c
)
78 "Compute the discriminant for a quadratic equation."
82 (locally (declare (number a b c
))
83 (- (* b b
) (* 4 a c
)))) => CAREFUL-DISCRIMINANT
84 (careful-discriminant 1 2/3 -
2) => 76/9
92 (asdf:oos
'asdf
:load-op
'versioned-objects
)
93 (asdf:oos
'asdf
:load-op
'validations
)
98 ;; SETUP FOR PLOT EXAMPLE:
101 (defpackage :cl-2d-user-x11
102 (:use
:cl
:cl-cairo2
:cl-2d
:cl-numlib
:cl-colors
:bind
))
104 (in-package :cl-2d-user-x11
)
111 ;; this is how you create an X11 frame. If you supply a
112 ;; background-color to as-frame, each plot will clear the frame with
115 (defparameter *frame1
* (as-frame (create-xlib-image-context 300 300)
116 :background-color
+white
+))
118 ;; or netbook size, picture is similar but on a lower-res display window.
119 (defparameter *frame2
* (as-frame (create-xlib-image-context 200 200)
120 :background-color
+white
+))
122 (plot-function *frame1
*
123 #'exp
(interval-of 0 2)
127 ;; split the frame, and you can draw on the subframes independently.
130 (bind ((#2A
((f1 f2
) (f3 f4
))
131 (split-frame *frame2
* (percent 50) (percent 50))))
132 (defparameter *f1
* f1
)
133 (defparameter *f2
* f2
)
134 (defparameter *f3
* f3
)
135 (defparameter *f4
* f4
))
138 (bind ((#2A
((f1 f2
) (f3 f4
))
139 (split-frame *frame2
* (percent 75) (percent 25))))
140 (defparameter *f1
* f1
)
141 (defparameter *f2
* f2
)
142 (defparameter *f3
* f3
)
143 (defparameter *f4
* f4
))
145 (plot-function *f1
* #'sin
(interval-of 0 2) :x-title
"x" :y-title
"sin(x)")
146 (plot-function *f2
* #'cos
(interval-of 0 2) :x-title
"x" :y-title
"cos(x)")
147 (plot-function *f3
* #'tan
(interval-of 0 2) :x-title
"x" :y-title
"tan(x)")
148 (plot-function *f4
* #'/ (interval-of 0 2) :x-title
"x" :y-title
"1/x")
154 (xs (num-sequence :from
0 :to
10 :length n
))
155 (ys (map 'vector
#'(lambda (x) (+ x
8 (random 4.0))) xs
))
156 (weights (replicate #'(lambda () (1+ (random 10))) n
'fixnum
))
157 (da (plot-simple *frame1
* (interval-of 0 10) (interval-of 10 20)
158 :x-title
"x" :y-title
"y")))
159 (draw-symbols da xs ys
:weights weights
))
161 (xlib-image-context-to-png (context *frame1
*) "/home/tony/test1.png")
162 (xlib-image-context-to-png (context *frame2
*) "/home/tony/test2.png")
166 ;;; EXAMPLE FOR DSC2009
167 (defparameter *frame2
* (as-frame (create-xlib-image-context 400 400)
168 :background-color
+white
+))
170 (bind ((#2A
((f1 f2
) (f3 f4
))
171 (split-frame *frame2
* (percent 50) (percent 50))))
172 (defparameter *f1
* f1
)
173 (defparameter *f2
* f2
)
174 (defparameter *f3
* f3
)
175 (defparameter *f4
* f4
))
176 (plot-function *f1
* #'sin
(interval-of 0 2) :x-title
"x" :y-title
"sin(x)")
177 (plot-function *f2
* #'cos
(interval-of 0 2) :x-title
"x" :y-title
"cos(x)")
178 (plot-function *f3
* #'tan
(interval-of 0 2) :x-title
"x" :y-title
"tan(x)")
180 (num-sequence :from
0 :to
10 :length
30)
183 (xs (num-sequence :from
0 :to
10 :length n
))
184 (ys (map 'vector
#'(lambda (x) (+ x
8 (random 4.0))) xs
))
185 (weights (replicate #'(lambda () (1+ (random 10))) n
'fixnum
))
186 (da (plot-simple *f4
* (interval-of 0 10) (interval-of 10 20)
187 :x-title
"x" :y-title
"y")))
188 (draw-symbols da xs ys
:weights weights
))
189 (xlib-image-context-to-png (context *f1
*) "/home/tony/test1.png")
190 (xlib-image-context-to-png (context *frame2
*) "/home/tony/test2.png")
191 (destroy (context *frame2
*))
195 ;; back to normal application
196 (in-package :ls-user
)
201 (with-data dataset
((dsvarname1 [usevarname1])
202 (dsvarname2 [usevarname2]))
209 (defun testme (&key (a 3) (b (+ a 3)))
215 (testme :a 2 :b (* a 5))