Fix types for some plot parameters

Thanks to Neil for providing test cases
This commit is contained in:
Asumu Takikawa 2013-06-18 12:25:58 -04:00
parent bafaf52056
commit 2f59f1027f
2 changed files with 108 additions and 25 deletions

View File

@ -0,0 +1,83 @@
#lang typed/racket
;; This test ensures that the types of plot parameters are
;; correct and can be set appropriately in TR.
(require plot/typed)
(interval-line1-style 1)
(interval-line2-style 3)
(plot (function-interval sub1 add1 0 1))
(rectangle-line-style 2)
(plot (rectangles (list (list (ivl 0 1) (ivl 0 1))
(list (ivl 1 2) (ivl 1 2)))))
;; ---------------------------------------------------------------------------------------------------
;; The following two plots should be the same
(contour-colors (λ (n) '((255 0 0) (0 0 255))))
(contour-widths (λ (n) '(.25 .5 .75)))
(contour-styles (λ (n) '(0 1 2)))
(contour-interval-colors (λ (n) '(1 2 3)))
(contour-interval-styles (λ (n) '(0 1 2)))
(contour-interval-alphas (λ (n) '(0.25 0.5 0.75)))
(plot (contour-intervals + 0 1 0 1))
(contour-colors '((255 0 0) (0 0 255)))
(contour-widths '(.25 .5 .75))
(contour-styles '(0 1 2))
(contour-interval-colors '(1 2 3))
(contour-interval-styles '(0 1 2))
(contour-interval-alphas '(0.25 0.5 0.75))
(plot (contour-intervals + 0 1 0 1))
;; ---------------------------------------------------------------------------------------------------
;; The following two plots should be the same
(stacked-histogram-alphas (λ (n) '(0.25 0.5 0.75)))
(stacked-histogram-colors (λ (n) '(1 2 3)))
(stacked-histogram-line-styles (λ (n) '(0 1 2)))
(stacked-histogram-styles (λ (n) '(0 1 2)))
(plot (stacked-histogram (list (list 'a '(1 1 1)) (list 'b '(1.5 3))
(list 'c '()) (list 'd '(1/2)))))
(stacked-histogram-alphas '(0.25 0.5 0.75))
(stacked-histogram-colors '(1 2 3))
(stacked-histogram-line-styles '(0 1 2))
(stacked-histogram-styles '(0 1 2))
(plot (stacked-histogram (list (list 'a '(1 1 1)) (list 'b '(1.5 3))
(list 'c '()) (list 'd '(1/2)))))
;; ---------------------------------------------------------------------------------------------------
;; The following two plots should be the same
(contour-interval-line-colors (λ (n) '(1 2 3)))
(contour-interval-line-widths (λ (n) '(0.25 0.5 0.75)))
(contour-interval-line-styles (λ (n) '(1 2 3)))
(plot3d (contour-intervals3d + 0 1 0 1))
(contour-interval-line-colors '(1 2 3))
(contour-interval-line-widths '(0.25 0.5 0.75))
(contour-interval-line-styles '(1 2 3))
(plot3d (contour-intervals3d + 0 1 0 1))
;; ---------------------------------------------------------------------------------------------------
;; The following two plots should be the same
(isosurface-colors (λ (n) '(1 2 3)))
(isosurface-styles (λ (n) '(0 1 2)))
(isosurface-line-colors (λ (n) '(3 2 1)))
(isosurface-line-widths (λ (n) '(0.25 0.5 0.75)))
(isosurface-line-styles (λ (n) '(0 1 2)))
(isosurface-alphas (λ (n) '(0.25 0.5 0.75)))
(plot3d (isosurfaces3d - 0 1 0 1 0 1))
(isosurface-colors '(1 2 3))
(isosurface-styles '(0 1 2))
(isosurface-line-colors '(3 2 1))
(isosurface-line-widths '(0.25 0.5 0.75))
(isosurface-line-styles '(0 1 2))
(isosurface-alphas '(0.25 0.5 0.75))
(plot3d (isosurfaces3d - 0 1 0 1 0 1))

View File

@ -61,10 +61,10 @@
[interval-style (Parameterof Plot-Brush-Style)] [interval-style (Parameterof Plot-Brush-Style)]
[interval-line1-color (Parameterof Plot-Color)] [interval-line1-color (Parameterof Plot-Color)]
[interval-line1-width (Parameterof Real Nonnegative-Real)] [interval-line1-width (Parameterof Real Nonnegative-Real)]
[interval-line1-style (Parameterof Plot-Pen-Styles)] [interval-line1-style (Parameterof Plot-Pen-Style)]
[interval-line2-color (Parameterof Plot-Color)] [interval-line2-color (Parameterof Plot-Color)]
[interval-line2-width (Parameterof Real Nonnegative-Real)] [interval-line2-width (Parameterof Real Nonnegative-Real)]
[interval-line2-style (Parameterof Plot-Pen-Styles)] [interval-line2-style (Parameterof Plot-Pen-Style)]
[interval-alpha (Parameterof Real)] [interval-alpha (Parameterof Real)]
;; 9.6 Points ;; 9.6 Points
@ -96,30 +96,30 @@
[contour-samples (Parameterof Integer Natural)] [contour-samples (Parameterof Integer Natural)]
[contour-levels (Parameterof (U 'auto Integer (Listof Real)) [contour-levels (Parameterof (U 'auto Integer (Listof Real))
(U 'auto Positive-Integer (Listof Real)))] (U 'auto Positive-Integer (Listof Real)))]
[contour-colors (Parameterof (U Plot-Colors (Listof Real)))] [contour-colors (Parameterof (Plot-Colors (Listof Real)))]
[contour-widths (Parameterof (U Pen-Widths (Listof Real)))] [contour-widths (Parameterof (Pen-Widths (Listof Real)))]
[contour-styles (Parameterof (U Plot-Pen-Styles (Listof Real)))] [contour-styles (Parameterof (Plot-Pen-Styles (Listof Real)))]
[contour-alphas (Parameterof (U Alphas (Listof Real)))] [contour-alphas (Parameterof (Alphas (Listof Real)))]
[contour-interval-colors (U Plot-Colors (Listof ivl))] [contour-interval-colors (Parameterof (Plot-Colors (Listof ivl)))]
[contour-interval-styles (U Plot-Brush-Styles (Listof ivl))] [contour-interval-styles (Parameterof (Plot-Brush-Styles (Listof ivl)))]
[contour-interval-alphas (U Alphas (Listof ivl))] [contour-interval-alphas (Parameterof (Alphas (Listof ivl)))]
;; 9.10 Rectangles ;; 9.10 Rectangles
[rectangle-color (Parameterof Plot-Color)] [rectangle-color (Parameterof Plot-Color)]
[rectangle-style (Parameterof Plot-Brush-Style)] [rectangle-style (Parameterof Plot-Brush-Style)]
[rectangle-line-color (Parameterof Plot-Color)] [rectangle-line-color (Parameterof Plot-Color)]
[rectangle-line-width (Parameterof Real Nonnegative-Real)] [rectangle-line-width (Parameterof Real Nonnegative-Real)]
[rectangle-line-style (Parameterof Plot-Pen-Styles)] [rectangle-line-style (Parameterof Plot-Pen-Style)]
[rectangle-alpha (Parameterof Real Nonnegative-Real)] [rectangle-alpha (Parameterof Real Nonnegative-Real)]
[rectangle3d-line-width (Parameterof Real Nonnegative-Real)] [rectangle3d-line-width (Parameterof Real Nonnegative-Real)]
[discrete-histogram-skip (Parameterof Real Nonnegative-Real)] [discrete-histogram-skip (Parameterof Real Nonnegative-Real)]
[discrete-histogram-invert? (Parameterof Boolean)] [discrete-histogram-invert? (Parameterof Boolean)]
[stacked-histogram-alphas (Parameterof (U Alphas Integer) (U Alphas Natural))] [stacked-histogram-alphas (Parameterof (Alphas Integer) (Alphas Natural))]
[stacked-histogram-colors (Parameterof (U Plot-Colors Integer) (U Plot-Colors Natural))] [stacked-histogram-colors (Parameterof (Plot-Colors Integer) (Plot-Colors Natural))]
[stacked-histogram-line-styles (Parameterof (U Plot-Pen-Styles Integer) [stacked-histogram-line-styles (Parameterof (Plot-Pen-Styles Integer)
(U Plot-Pen-Styles Natural))] (Plot-Pen-Styles Natural))]
[stacked-histogram-styles (Parameterof (U Plot-Brush-Styles Integer) [stacked-histogram-styles (Parameterof (Plot-Brush-Styles Integer)
(U Plot-Brush-Styles Natural))] (Plot-Brush-Styles Natural))]
;; 9.11 Decorations ;; 9.11 Decorations
[x-axis-alpha (Parameterof Real Nonnegative-Real)] [x-axis-alpha (Parameterof Real Nonnegative-Real)]
@ -159,20 +159,20 @@
[surface-alpha (Parameterof Real Nonnegative-Real)] [surface-alpha (Parameterof Real Nonnegative-Real)]
;; 9.14 Contour Surfaces ;; 9.14 Contour Surfaces
[contour-interval-line-colors (Parameterof (U Plot-Colors (Listof ivl)))] [contour-interval-line-colors (Parameterof (Plot-Colors (Listof ivl)))]
[contour-interval-line-widths (Parameterof (U Pen-Widths (Listof ivl)))] [contour-interval-line-widths (Parameterof (Pen-Widths (Listof ivl)))]
[contour-interval-line-styles (Parameterof (U Plot-Pen-Styles (Listof ivl)))] [contour-interval-line-styles (Parameterof (Plot-Pen-Styles (Listof ivl)))]
;; 9.15 Isosurfaces ;; 9.15 Isosurfaces
[default-isosurface-colors ((Listof Real) -> (Listof Plot-Color))] [default-isosurface-colors ((Listof Real) -> (Listof Plot-Color))]
[default-isosurface-line-colors ((Listof Real) -> (Listof Plot-Color))] [default-isosurface-line-colors ((Listof Real) -> (Listof Plot-Color))]
[isosurface-levels (Parameterof (U 'auto Integer (Listof Real)) (U 'auto Natural (Listof Real)))] [isosurface-levels (Parameterof (U 'auto Integer (Listof Real)) (U 'auto Natural (Listof Real)))]
[isosurface-colors (Parameterof (U Plot-Colors (Listof Real)))] [isosurface-colors (Parameterof (Plot-Colors (Listof Real)))]
[isosurface-styles (Parameterof (U Plot-Brush-Styles (Listof Real)))] [isosurface-styles (Parameterof (Plot-Brush-Styles (Listof Real)))]
[isosurface-line-colors (Parameterof (U Plot-Colors (Listof Real)))] [isosurface-line-colors (Parameterof (Plot-Colors (Listof Real)))]
[isosurface-line-widths (U Pen-Widths (Listof Real))] [isosurface-line-widths (Parameterof (Pen-Widths (Listof Real)))]
[isosurface-line-styles (U Plot-Pen-Styles (Listof Real))] [isosurface-line-styles (Parameterof (Plot-Pen-Styles (Listof Real)))]
[isosurface-alphas (U Alphas (Listof Real))] [isosurface-alphas (Parameterof (Alphas (Listof Real)))]
;; 7.1 Axis Transforms ;; 7.1 Axis Transforms
[plot-x-transform (Parameterof Axis-Transform)] [plot-x-transform (Parameterof Axis-Transform)]