Skip to content

Commit f4849be

Browse files
committed
Get rid of last vestiges of unstable/latent-contract
1 parent 63b6323 commit f4849be

File tree

8 files changed

+263
-159
lines changed

8 files changed

+263
-159
lines changed

plot-compat/info.rkt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"plot-gui-lib"
77
"draw-lib"
88
"plot-lib"
9-
"snip-lib"
10-
"unstable-latent-contract-lib"))
9+
"snip-lib"))
1110

1211
(define build-deps '())
1312

plot-compat/plot/private/compat.rkt

Lines changed: 146 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
;; A compatibility module for the old 'plot'.
44

55
(require racket/contract racket/class racket/snip racket/draw racket/vector
6-
unstable/latent-contract unstable/latent-contract/defthing
76
;; Plotting
87
plot/private/common/math
98
plot/private/common/contract
@@ -23,15 +22,96 @@
2322
;; Miscellaneous
2423
plot/private/deprecated/math)
2524

26-
(provide mix
27-
(activate-contract-out plot-color?
28-
plot plot3d
29-
points vector-field error-bars
30-
line
31-
contour shade
32-
surface)
33-
;; Miscellaneous
34-
make-vec derivative gradient)
25+
(provide
26+
mix
27+
(contract-out
28+
[plot-color? (-> any/c boolean?)]
29+
[plot
30+
(->* [((is-a?/c 2d-plot-area%) . -> . void?)]
31+
[#:width real?
32+
#:height real?
33+
#:x-min real?
34+
#:x-max real?
35+
#:y-min real?
36+
#:y-max real?
37+
#:x-label string?
38+
#:y-label string?
39+
#:title string?
40+
#:fgcolor (list/c byte? byte? byte?)
41+
#:bgcolor (list/c byte? byte? byte?)
42+
#:lncolor (list/c byte? byte? byte?)
43+
#:out-file (or/c path-string? output-port? #f)]
44+
(is-a?/c image-snip%))]
45+
[plot3d
46+
(->* [((is-a?/c 3d-plot-area%) . -> . void?)]
47+
[#:width real?
48+
#:height real?
49+
#:x-min real?
50+
#:x-max real?
51+
#:y-min real?
52+
#:y-max real?
53+
#:z-min real?
54+
#:z-max real?
55+
#:alt real?
56+
#:az real?
57+
#:x-label string?
58+
#:y-label string?
59+
#:z-label string?
60+
#:title string?
61+
#:fgcolor (list/c byte? byte? byte?)
62+
#:bgcolor (list/c byte? byte? byte?)
63+
#:lncolor (list/c byte? byte? byte?)
64+
#:out-file (or/c path-string? output-port? #f)]
65+
(is-a?/c image-snip%))]
66+
[points
67+
(->* [(listof (vectorof real?))]
68+
[#:sym (or/c char? string? exact-integer? symbol?)
69+
#:color plot-color?]
70+
((is-a?/c 2d-plot-area%) . -> . void?))]
71+
[vector-field
72+
(->* [((vector/c real? real?) . -> . (vector/c real? real?))]
73+
[#:samples (and/c exact-integer? (>=/c 2))
74+
#:width exact-positive-integer?
75+
#:color plot-color?
76+
#:style (one-of/c 'scaled 'normalized 'real)]
77+
((is-a?/c 2d-plot-area%) . -> . void?))]
78+
[error-bars
79+
(->* [(listof (vector/c real? real? real?))]
80+
[#:color plot-color?]
81+
((is-a?/c 2d-plot-area%) . -> . void?))]
82+
[line
83+
(->* [(real? . -> . (or/c real? (vector/c real? real?)))]
84+
[#:samples (and/c exact-integer? (>=/c 2))
85+
#:width (>=/c 0)
86+
#:color plot-color/c
87+
#:mode (one-of/c 'standard 'parametric)
88+
#:mapping (one-of/c 'cartesian 'polar)
89+
#:t-min real?
90+
#:t-max real?]
91+
((is-a?/c 2d-plot-area%) . -> . void?))]
92+
[contour
93+
(->* [(real? real? . -> . real?)]
94+
[#:samples exact-nonnegative-integer?
95+
#:width (>=/c 0)
96+
#:color plot-color/c
97+
#:levels (or/c (and/c exact-integer? (>=/c 2)) (listof real?))]
98+
((is-a?/c 2d-plot-area%) . -> . void?))]
99+
[shade
100+
(->* [(real? real? . -> . real?)]
101+
[#:samples (and/c exact-integer? (>=/c 2))
102+
#:levels (or/c (and/c exact-integer? (>=/c 2)) (listof real?))]
103+
((is-a?/c 2d-plot-area%) . -> . void?))]
104+
[surface
105+
(->* [(real? real? . -> . real?)]
106+
[#:samples (and/c exact-integer? (>=/c 2))
107+
#:width (>=/c 0)
108+
#:color plot-color/c]
109+
((is-a?/c 3d-plot-area%) . -> . void?))]
110+
)
111+
;; Miscellaneous
112+
make-vec
113+
derivative
114+
gradient)
35115

36116
(define (mix . data)
37117
(for/fold ([f (λ (area) (void))]) ([d (in-list data)])
@@ -40,7 +120,7 @@
40120
(d area)
41121
(void))))
42122

43-
(defproc (plot-color? [v any/c]) boolean?
123+
(define (plot-color? v)
44124
(and (member v '(white black yellow green aqua pink wheat gray brown blue violet cyan
45125
turquoise magenta salmon red))
46126
#t))
@@ -59,17 +139,20 @@
59139
(define x-axis-data (renderer2d->plot-data (new.x-axis)))
60140
(define y-axis-data (renderer2d->plot-data (new.y-axis)))
61141

62-
(defproc (plot [data ((is-a?/c 2d-plot-area%) . -> . void?)]
63-
[#:width width real? 400] [#:height height real? 400]
64-
[#:x-min x-min real? -5] [#:x-max x-max real? 5]
65-
[#:y-min y-min real? -5] [#:y-max y-max real? 5]
66-
[#:x-label x-label string? "X axis"] [#:y-label y-label string? "Y axis"]
67-
[#:title title string? ""]
68-
[#:fgcolor fgcolor (list/c byte? byte? byte?) '(0 0 0)]
69-
[#:bgcolor bgcolor (list/c byte? byte? byte?) '(255 255 255)]
70-
[#:lncolor lncolor (list/c byte? byte? byte?) '(255 0 0)]
71-
[#:out-file out-file (or/c path-string? output-port? #f) #f]
72-
) (is-a?/c image-snip%)
142+
(define (plot data
143+
#:width [width 400]
144+
#:height [height 400]
145+
#:x-min [x-min -5]
146+
#:x-max [x-max 5]
147+
#:y-min [y-min -5]
148+
#:y-max [y-max 5]
149+
#:x-label [x-label "X axis"]
150+
#:y-label [y-label "Y axis"]
151+
#:title [title ""]
152+
#:fgcolor [fgcolor '(0 0 0)]
153+
#:bgcolor [bgcolor '(255 255 255)]
154+
#:lncolor [lncolor '(255 0 0)]
155+
#:out-file [out-file #f])
73156
(define x-ticks (ticks-generate (new.plot-x-ticks) x-min x-max))
74157
(define y-ticks (ticks-generate (new.plot-y-ticks) y-min y-max))
75158
(define bounds-rect (vector (ivl x-min x-max) (ivl y-min y-max)))
@@ -96,22 +179,25 @@
96179

97180
(make-object image-snip% bm)))
98181

99-
(defproc (plot3d [data ((is-a?/c 3d-plot-area%) . -> . void?)]
100-
[#:width width real? 400] [#:height height real? 400]
101-
[#:x-min x-min real? -5] [#:x-max x-max real? 5]
102-
[#:y-min y-min real? -5] [#:y-max y-max real? 5]
103-
[#:z-min z-min real? -5] [#:z-max z-max real? 5]
104-
[#:alt alt real? 30]
105-
[#:az az real? 45]
106-
[#:x-label x-label string? "X axis"]
107-
[#:y-label y-label string? "Y axis"]
108-
[#:z-label z-label string? "Z axis"]
109-
[#:title title string? ""]
110-
[#:fgcolor fgcolor (list/c byte? byte? byte?) '(0 0 0)]
111-
[#:bgcolor bgcolor (list/c byte? byte? byte?) '(255 255 255)]
112-
[#:lncolor lncolor (list/c byte? byte? byte?) '(255 0 0)]
113-
[#:out-file out-file (or/c path-string? output-port? #f) #f]
114-
) (is-a?/c image-snip%)
182+
(define (plot3d data
183+
#:width [width 400]
184+
#:height [height 400]
185+
#:x-min [x-min -5]
186+
#:x-max [x-max 5]
187+
#:y-min [y-min -5]
188+
#:y-max [y-max 5]
189+
#:z-min [z-min -5]
190+
#:z-max [z-max 5]
191+
#:alt [alt 30]
192+
#:az [az 45]
193+
#:x-label [x-label "X axis"]
194+
#:y-label [y-label "Y axis"]
195+
#:z-label [z-label "Z axis"]
196+
#:title [title ""]
197+
#:fgcolor [fgcolor '(0 0 0)]
198+
#:bgcolor [bgcolor '(255 255 255)]
199+
#:lncolor [lncolor '(255 0 0)]
200+
#:out-file [out-file #f])
115201
(define x-ticks (ticks-generate (new.plot-x-ticks) x-min x-max))
116202
(define y-ticks (ticks-generate (new.plot-y-ticks) y-min y-max))
117203
(define z-ticks (ticks-generate (new.plot-z-ticks) z-min z-max))
@@ -143,58 +229,44 @@
143229
;; ===================================================================================================
144230
;; Functions that generate "plot data"
145231

146-
(defproc (points [vecs (listof (vectorof real?))]
147-
[#:sym sym (or/c char? string? exact-integer? symbol?) 'square]
148-
[#:color color plot-color? 'black]
149-
) ((is-a?/c 2d-plot-area%) . -> . void?)
232+
(define (points vecs #:sym [sym 'square] #:color [color 'black])
150233
(renderer2d->plot-data (new.points (map (λ (v) (vector-take v 2)) vecs)
151234
#:sym sym #:size 6 #:color color)))
152235

153-
(defproc (vector-field [f ((vector/c real? real?) . -> . (vector/c real? real?))]
154-
[#:samples samples (and/c exact-integer? (>=/c 2)) 20]
155-
[#:width width exact-positive-integer? 1]
156-
[#:color color plot-color? 'red]
157-
[#:style style (one-of/c 'scaled 'normalized 'real) 'scaled]
158-
) ((is-a?/c 2d-plot-area%) . -> . void?)
236+
(define (vector-field f
237+
#:samples [samples 20]
238+
#:width [width 1]
239+
#:color [color 'red]
240+
#:style [style 'scaled])
159241
(define scale (case style
160242
[(scaled) 'auto]
161243
[(normalized) 'normalized]
162244
[(real) 1.0]))
163245
(renderer2d->plot-data
164246
(new.vector-field f #:samples samples #:line-width width #:color color #:scale scale)))
165247

166-
(defproc (error-bars [vecs (listof (vector/c real? real? real?))]
167-
[#:color color plot-color? 'black]
168-
) ((is-a?/c 2d-plot-area%) . -> . void?)
248+
(define (error-bars vecs #:color [color 'black])
169249
(renderer2d->plot-data (new.error-bars vecs #:color color #:alpha 1 #:width 4)))
170250

171-
(defproc (line [f (real? . -> . (or/c real? (vector/c real? real?)))]
172-
[#:samples samples (and/c exact-integer? (>=/c 2)) 150]
173-
[#:width width (>=/c 0) 1]
174-
[#:color color plot-color/c 'red]
175-
[#:mode mode (one-of/c 'standard 'parametric) 'standard]
176-
[#:mapping mapping (one-of/c 'cartesian 'polar) 'cartesian]
177-
[#:t-min t-min real? -5] [#:t-max t-max real? 5]
178-
) ((is-a?/c 2d-plot-area%) . -> . void?)
251+
(define (line f
252+
#:samples [samples 150]
253+
#:width [width 1]
254+
#:color [color 'red]
255+
#:mode [mode 'standard]
256+
#:mapping [mapping 'cartesian]
257+
#:t-min [t-min -5]
258+
#:t-max [t-max 5])
179259
(renderer2d->plot-data (line-renderer f samples width color mode mapping t-min t-max)))
180260

181-
(defproc (contour [f (real? real? . -> . real?)]
182-
[#:samples samples exact-nonnegative-integer? 50]
183-
[#:width width (>=/c 0) 1]
184-
[#:color color plot-color/c 'black]
185-
[#:levels levels (or/c (and/c exact-integer? (>=/c 2)) (listof real?)) 10]
186-
) ((is-a?/c 2d-plot-area%) . -> . void?)
261+
(define (contour f
262+
#:samples [samples 50]
263+
#:width [width 1]
264+
#:color [color 'black]
265+
#:levels [levels 10])
187266
(renderer2d->plot-data (contour-renderer f samples width color levels)))
188267

189-
(defproc (shade [f (real? real? . -> . real?)]
190-
[#:samples samples (and/c exact-integer? (>=/c 2)) 50]
191-
[#:levels levels (or/c (and/c exact-integer? (>=/c 2)) (listof real?)) 10]
192-
) ((is-a?/c 2d-plot-area%) . -> . void?)
268+
(define (shade f #:samples [samples 50] #:levels [levels 10])
193269
(renderer2d->plot-data (shade-renderer f samples levels)))
194270

195-
(defproc (surface [f (real? real? . -> . real?)]
196-
[#:samples samples (and/c exact-integer? (>=/c 2)) 50]
197-
[#:width width (>=/c 0) 1]
198-
[#:color color plot-color/c 'black]
199-
) ((is-a?/c 3d-plot-area%) . -> . void?)
271+
(define (surface f #:samples [samples 50] #:width [width 1] #:color [color 'black])
200272
(renderer3d->plot-data (surface-renderer f samples width color)))

plot-doc/info.rkt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
"slideshow-doc"
2121
"slideshow-lib"
2222
"srfi-doc"
23-
"unstable-contract-lib"
24-
"unstable-doc"))
23+
"unstable-doc"
24+
"unstable-contract-lib"))
25+
2526
(define update-implies '("plot-lib"))
2627

2728
(define pkg-desc "Documentation for plot")

plot-lib/info.rkt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"typed-racket-lib"
1111
"typed-racket-more"
1212
"compatibility-lib"
13-
"math-lib"
14-
"unstable-latent-contract-lib"))
13+
"math-lib"))
1514

1615
(define build-deps '())
1716

plot-lib/plot/no-gui.rkt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#lang racket/base
22

3-
(require unstable/latent-contract)
4-
53
;; ===================================================================================================
64
;; General exports
75

@@ -132,8 +130,7 @@
132130
(require "private/deprecated/deprecated.rkt")
133131
(provide
134132
mix
135-
(activate-contract-out
136-
line
137-
contour
138-
shade
139-
surface))
133+
line
134+
contour
135+
shade
136+
surface)

0 commit comments

Comments
 (0)