Moved contract/c and treeof to unstable/contracts
Little plot doc fixes
This commit is contained in:
parent
ec96e37e09
commit
7d28eef00d
|
@ -4,27 +4,16 @@
|
||||||
unstable/latent-contract/defthing)
|
unstable/latent-contract/defthing)
|
||||||
|
|
||||||
(provide (except-out (all-defined-out)
|
(provide (except-out (all-defined-out)
|
||||||
treeof
|
|
||||||
maybe-function/c maybe-apply
|
maybe-function/c maybe-apply
|
||||||
plot-colors/c pen-widths/c plot-pen-styles/c plot-brush-styles/c alphas/c
|
plot-colors/c pen-widths/c plot-pen-styles/c plot-brush-styles/c alphas/c
|
||||||
labels/c)
|
labels/c)
|
||||||
(activate-contract-out
|
(activate-contract-out
|
||||||
treeof
|
|
||||||
maybe-function/c maybe-apply
|
maybe-function/c maybe-apply
|
||||||
plot-colors/c pen-widths/c plot-pen-styles/c plot-brush-styles/c alphas/c
|
plot-colors/c pen-widths/c plot-pen-styles/c plot-brush-styles/c alphas/c
|
||||||
labels/c)
|
labels/c)
|
||||||
(rename-out [natural-number/c nat/c])
|
(rename-out [natural-number/c nat/c])
|
||||||
truth/c)
|
truth/c)
|
||||||
|
|
||||||
;; ===================================================================================================
|
|
||||||
;; Convenience
|
|
||||||
|
|
||||||
(defcontract contract/c (or/c contract? (any/c . -> . any/c)))
|
|
||||||
|
|
||||||
(defcontract (treeof [elem-contract contract/c])
|
|
||||||
(or/c elem-contract
|
|
||||||
(listof (recursive-contract (treeof elem-contract)))))
|
|
||||||
|
|
||||||
;; ===================================================================================================
|
;; ===================================================================================================
|
||||||
;; Plot-specific contracts
|
;; Plot-specific contracts
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require racket/contract unstable/latent-contract racket/class)
|
(require racket/contract unstable/latent-contract unstable/contract racket/class)
|
||||||
|
|
||||||
(require "../common/contract.rkt"
|
(require "../common/contract.rkt"
|
||||||
"../common/plot-element.rkt"
|
"../common/plot-element.rkt"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
;; Procedures that plot 2D renderers.
|
;; Procedures that plot 2D renderers.
|
||||||
|
|
||||||
(require racket/draw racket/snip racket/contract racket/list racket/class racket/match
|
(require racket/draw racket/snip racket/contract racket/list racket/class racket/match
|
||||||
|
unstable/contract
|
||||||
slideshow/pict
|
slideshow/pict
|
||||||
unstable/parameter-group
|
unstable/parameter-group
|
||||||
unstable/lazy-require
|
unstable/lazy-require
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
;; Procedures that plot 3D renderers.
|
;; Procedures that plot 3D renderers.
|
||||||
|
|
||||||
(require racket/draw racket/snip racket/match racket/list racket/class racket/contract
|
(require racket/draw racket/snip racket/match racket/list racket/class racket/contract
|
||||||
|
unstable/contract
|
||||||
slideshow/pict
|
slideshow/pict
|
||||||
unstable/parameter-group
|
unstable/parameter-group
|
||||||
unstable/lazy-require
|
unstable/lazy-require
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
slideshow/pict
|
slideshow/pict
|
||||||
db
|
db
|
||||||
plot
|
plot
|
||||||
plot/utils)
|
plot/utils
|
||||||
|
unstable/contract)
|
||||||
plot
|
plot
|
||||||
plot/utils
|
plot/utils
|
||||||
plot/doc
|
plot/doc
|
||||||
|
@ -19,7 +20,8 @@
|
||||||
slideshow/pict
|
slideshow/pict
|
||||||
db
|
db
|
||||||
plot
|
plot
|
||||||
plot/utils))
|
plot/utils
|
||||||
|
unstable/contract))
|
||||||
(all-from-out plot)
|
(all-from-out plot)
|
||||||
(all-from-out plot/doc)
|
(all-from-out plot/doc)
|
||||||
(all-from-out plot/utils)
|
(all-from-out plot/utils)
|
||||||
|
|
|
@ -137,14 +137,3 @@ Like @(racket plot-colors/c), but for opacities.
|
||||||
Like @racket[plot-colors/c], but for strings.
|
Like @racket[plot-colors/c], but for strings.
|
||||||
This is used, for example, to label @racket[stacked-histogram]s.
|
This is used, for example, to label @racket[stacked-histogram]s.
|
||||||
}
|
}
|
||||||
|
|
||||||
@section{Convenience Contracts}
|
|
||||||
|
|
||||||
@doc-apply[contract/c]{
|
|
||||||
Identifies @racket[contract?]s and predicates that can be used as contracts.
|
|
||||||
}
|
|
||||||
|
|
||||||
@doc-apply[treeof]{
|
|
||||||
Identifies trees of values that meet the contract @(racket ct).
|
|
||||||
Used by @(racket plot) and @(racket plot3d) to construct the contract for a tree of @(racket renderer2d?) or @(racket renderer3d?).
|
|
||||||
}
|
|
||||||
|
|
|
@ -268,19 +268,23 @@ Returns @racket[#t] if @racket[x] is @racket[+nan.0].
|
||||||
}
|
}
|
||||||
|
|
||||||
@doc-apply[ceiling-log/base]{
|
@doc-apply[ceiling-log/base]{
|
||||||
Like @racket[(ceiling (/ (log x) (log b)))], but @racket[ceiling-log/base] is not susceptible to floating-point error when given an exact @racket[x].
|
Like @racket[(ceiling (/ (log x) (log b)))], but @racket[ceiling-log/base] is not susceptible to floating-point error.
|
||||||
@examples[#:eval plot-eval
|
@examples[#:eval plot-eval
|
||||||
|
(ceiling (/ (log 100) (log 10)))
|
||||||
|
(ceiling-log/base 10 100)
|
||||||
(ceiling (/ (log 1/1000) (log 10)))
|
(ceiling (/ (log 1/1000) (log 10)))
|
||||||
(ceiling-log/base 10 1/1000)]
|
(ceiling-log/base 10 1/1000)]
|
||||||
Various number-formatting functions use this.
|
Various number-formatting functions use this.
|
||||||
}
|
}
|
||||||
|
|
||||||
@doc-apply[floor-log/base]{
|
@doc-apply[floor-log/base]{
|
||||||
Like @racket[(floor (/ (log x) (log b)))], but @racket[floor-log/base] is not susceptible to floating-point error when given an exact @racket[x].
|
Like @racket[(floor (/ (log x) (log b)))], but @racket[floor-log/base] is not susceptible to floating-point error.
|
||||||
@examples[#:eval plot-eval
|
@examples[#:eval plot-eval
|
||||||
|
(floor (/ (log 100) (log 10)))
|
||||||
|
(floor-log/base 10 100)
|
||||||
(floor (/ (log 1000) (log 10)))
|
(floor (/ (log 1000) (log 10)))
|
||||||
(floor-log/base 10 1000)]
|
(floor-log/base 10 1000)]
|
||||||
Various number-formatting functions use this.
|
This is a generalization of @racket[order-of-magnitude].
|
||||||
}
|
}
|
||||||
|
|
||||||
@doc-apply[maybe-inexact->exact]{
|
@doc-apply[maybe-inexact->exact]{
|
||||||
|
@ -506,10 +510,6 @@ See @racket[date-ticks] for more information.
|
||||||
|
|
||||||
To plot a time series using dates pulled from an SQL database, simply set the relevant axis ticks (probably @racket[plot-x-ticks]) to @racket[date-ticks], and convert the dates to seconds using @racket[datetime->real] before passing them to @racket[lines].
|
To plot a time series using dates pulled from an SQL database, simply set the relevant axis ticks (probably @racket[plot-x-ticks]) to @racket[date-ticks], and convert the dates to seconds using @racket[datetime->real] before passing them to @racket[lines].
|
||||||
To keep time zone offsets from influencing the plot, set them to @racket[0] first.
|
To keep time zone offsets from influencing the plot, set them to @racket[0] first.
|
||||||
|
|
||||||
Does @racket[sql-time?] work?
|
|
||||||
|
|
||||||
@racketmodname[db/base]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@defstruct[plot-time ([second (and/c (>=/c 0) (</c 60))]
|
@defstruct[plot-time ([second (and/c (>=/c 0) (</c 60))]
|
||||||
|
|
|
@ -171,6 +171,14 @@
|
||||||
(lambda (idx . elems) #t)))))))
|
(lambda (idx . elems) #t)))))))
|
||||||
sequence?)))
|
sequence?)))
|
||||||
|
|
||||||
|
;; Added by ntoronto
|
||||||
|
|
||||||
|
(define contract/c (or/c contract? (any/c . -> . any/c)))
|
||||||
|
|
||||||
|
(define (treeof elem-contract)
|
||||||
|
(or/c elem-contract
|
||||||
|
(listof (recursive-contract (treeof elem-contract) #:flat))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;
|
;;
|
||||||
;; Exports
|
;; Exports
|
||||||
|
@ -192,4 +200,9 @@
|
||||||
[truth/c flat-contract?]
|
[truth/c flat-contract?]
|
||||||
|
|
||||||
[sequence/c (->* [] [] #:rest (listof contract?) contract?)]
|
[sequence/c (->* [] [] #:rest (listof contract?) contract?)]
|
||||||
|
|
||||||
|
[contract/c contract?]
|
||||||
|
|
||||||
|
[treeof (contract/c . -> . contract?)]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -116,4 +116,22 @@ for instance, a wrapped list is not guaranteed to satisfy @racket[list?].
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@addition{@author+email["Neil Toronto" "neil.toronto@gmail.com"]}
|
||||||
|
|
||||||
|
@defthing[contract/c contract?]{
|
||||||
|
Identifies contracts and predicates that can be used as contracts.
|
||||||
|
}
|
||||||
|
|
||||||
|
@defproc[(treeof [elem-contract contract/c]) contract?]{
|
||||||
|
Identifies values that meet the contract @racket[elem-contract], lists of such values, lists of lists, and so on.
|
||||||
|
@examples[#:eval the-eval
|
||||||
|
(define number-tree/c (treeof number?))
|
||||||
|
(flat-contract? number-tree/c)
|
||||||
|
(define number-tree? (flat-contract-predicate number-tree/c))
|
||||||
|
(number-tree? 4)
|
||||||
|
(number-tree? '(4 5))
|
||||||
|
(number-tree? '((4 5) 6))
|
||||||
|
(number-tree? '(4 . 5))]
|
||||||
|
}
|
||||||
|
|
||||||
@(close-eval the-eval)
|
@(close-eval the-eval)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user