<div>I'm not sure about this change. If I pass in a buggy function, I'm not sure I'd want the errors to get swallowed.</div><div><br></div>How about making the plot but putting a red thing on it (and maybe showing the error text on mouseover)?<div>
<br></div><div>Or maybe making this optional behavior?</div><div><br></div><div>Robby</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 17, 2012 at 6:02 PM, <span dir="ltr"><<a href="mailto:ntoronto@racket-lang.org" target="_blank">ntoronto@racket-lang.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ntoronto has updated `master' from d120286f89 to 2657d8f96b.<br>
<a href="http://git.racket-lang.org/plt/d120286f89..2657d8f96b" target="_blank">http://git.racket-lang.org/plt/d120286f89..2657d8f96b</a><br>
<br>
=====[ One Commit ]=====================================================<br>
Directory summary:<br>
92.4% collects/plot/common/<br>
7.5% collects/plot/tests/<br>
<br>
~~~~~~~~~~<br>
<br>
2657d8f Neil Toronto <<a href="mailto:ntoronto@racket-lang.org">ntoronto@racket-lang.org</a>> 2012-12-17 16:58<br>
:<br>
| Plots whose functions raise errors now have an empty spot instead of<br>
| failing<br>
:<br>
M collects/plot/common/sample.rkt | 9 ++++++---<br>
M collects/plot/tests/plot2d-tests.rkt | 2 ++<br>
<br>
=====[ Overall Diff ]===================================================<br>
<br>
collects/plot/common/sample.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/collects/plot/common/sample.rkt<br>
+++ NEW/collects/plot/common/sample.rkt<br>
@@ -134,7 +134,8 @@<br>
<br>
(defproc (make-function->sampler [transform-thnk (-> axis-transform/c)]<br>
) (-> (real? . -> . real?) ivl? sampler/c)<br>
- (λ (f inner-ivl)<br>
+ (λ (g inner-ivl)<br>
+ (define f (λ (x) (with-handlers ([exn:fail? (λ (_) +nan.0)]) (g x))))<br>
(define memo (make-hash))<br>
(λ (outer-ivl num)<br>
(define tx (transform-thnk))<br>
@@ -155,7 +156,8 @@<br>
) (-> (real? real? . -> . real?)<br>
(vector/c ivl? ivl?)<br>
2d-sampler/c)<br>
- (λ (f inner-rect)<br>
+ (λ (g inner-rect)<br>
+ (define f (λ (x y) (with-handlers ([exn:fail? (λ (_) +nan.0)]) (g x y))))<br>
(define memo (make-hash))<br>
(λ (outer-rect nums)<br>
(define tx (transform-x-thnk))<br>
@@ -186,7 +188,8 @@<br>
) (-> (real? real? real? . -> . real?)<br>
(vector/c ivl? ivl? ivl?)<br>
3d-sampler/c)<br>
- (λ (f inner-rect)<br>
+ (λ (g inner-rect)<br>
+ (define f (λ (x y z) (with-handlers ([exn:fail? (λ (_) +nan.0)]) (g x y z))))<br>
(define memo (make-hash))<br>
(λ (outer-rect nums)<br>
(define tx (transform-x-thnk))<br>
<br>
collects/plot/tests/plot2d-tests.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/collects/plot/tests/plot2d-tests.rkt<br>
+++ NEW/collects/plot/tests/plot2d-tests.rkt<br>
@@ -4,6 +4,8 @@<br>
<br>
;(plot-new-window? #t)<br>
<br>
+(plot (function / -249 250))<br>
+<br>
(time<br>
(define xs (build-list 10000 (λ _ (random))))<br>
(plot (density xs 1/2)))<br>
</blockquote></div><br></div>