1.5.4 Writing to a file
With #:out-file, both plot procedures also write the plot to a file, in the format its extension names (see image-path/c). They still return the pict. Any other extension breaks their contract:
> (define file (make-temporary-file "cv-~a.png")) > (void (plot-cv cv #:out-file file)) > (call-with-input-file file (lambda (in) (read-bytes 4 in))) #"\211PNG"
> (delete-file file) > (plot-cv cv #:out-file "cv.jpg") plot-cv: contract violation
expected: (or/c #f image-path/c)
given: "cv.jpg"
in: the #:out-file argument of
(->*
((or/c glmnet-cv? formula-model?))
(#:height
exact-positive-integer?
#:out-file
(or/c #f image-path/c)
#:sign-lambda
(or/c -1 1)
#:title
(or/c #f string?)
#:width
exact-positive-integer?)
pict?)
contract from: <pkgs>/glmnet/plot.rkt
blaming: program
(assuming the contract is correct)
at: <pkgs>/glmnet/plot.rkt:82:3