Test case for Richard Hollos

This commit is contained in:
Neil Toronto 2011-11-09 12:52:57 -07:00
parent bf2fbbbc49
commit 86a862cca9
3 changed files with 40 additions and 0 deletions

View File

@ -15,6 +15,10 @@
[(invertible-function f2 g2) f2])
(invertible-function (compose f1 f2) (compose g2 g1))))
(defproc (invertible-inverse [h invertible-function?]) invertible-function?
(match-define (invertible-function f g) h)
(invertible-function g f))
(defcontract axis-transform/c (real? real? invertible-function? . -> . invertible-function?))
(defproc (id-transform [x-min real?] [x-max real?] [old-function invertible-function?]

View File

@ -6,6 +6,8 @@
(provide (contract-out (struct invertible-function ([f (real? . -> . real?)]
[g (real? . -> . real?)])))
(activate-contract-out id-function
invertible-compose
invertible-inverse
axis-transform/c
id-transform
apply-axis-transform

View File

@ -158,3 +158,37 @@
(plot (function sin -4 4)
#:title "Hello")
(plot3d (contour-intervals3d (λ (x y) (- (sqr x) (sqr y))) -2 2 -2 2))))
(time
(define ((degrees-ticks-format suffix) x-min x-max ts)
(map (λ (label) (format "~a\ub0~a" label suffix))
((linear-ticks-format) x-min x-max ts)))
(define C-ticks (ticks (linear-ticks-layout) (degrees-ticks-format 'C)))
(define F/C-ticks (ticks-scale
(ticks (linear-ticks-layout) (degrees-ticks-format 'F))
(linear-scale 9/5 32)))
(define data (list #(0 0) #(15 0.6) #(30 9.5) #(45 10.0) #(60 16.6)
#(75 41.6) #(90 42.7) #(105 65.5) #(120 78.9)
#(135 78.9) #(150 131.1) #(165 151.1) #(180 176.2)))
(define (temp/time-trend x) (/ (sqr x) 180))
(define above-data (filter (λ (v) (match-let ([(vector x y) v])
(y . > . (temp/time-trend x))))
data))
(parameterize ([plot-x-ticks (time-ticks)]
[plot-y-ticks C-ticks]
[plot-y-far-ticks F/C-ticks])
(plot (list (function temp/time-trend 0 180 #:style 'long-dash #:color 3
#:label "Trend")
(lines data #:color 2 #:width 2)
(points data #:color 1 #:line-width 2 #:label "Measurement")
(map (λ (d) (point-label d #:anchor 'bottom-right))
above-data))
#:y-min -25 #:x-label "Time" #:y-label "Temp."
#:title "Temp./Time With Applied Heat (Measurement and Trend)")))