From a14222e19736f75bdb9c660ca9c3b78c6e2ee9b3 Mon Sep 17 00:00:00 2001 From: Sam Tobin-Hochstadt Date: Mon, 1 Apr 2024 12:12:00 -0400 Subject: [PATCH] Repair errors uncovered by racket/typed-racket#1367. (#129) Some arguments were not type checked correctly, meaning some type errors slipped through. The most significant change is that the jitter parameters become `Nonnegative-Real`, which is backwards-incompatible. Other choices there are possible, but this is the simplest. --- plot-lib/plot/private/common/parameters.rkt | 6 +++--- plot-lib/plot/private/common/plot-device.rkt | 4 ++-- plot-lib/plot/private/plot2d/point.rkt | 2 +- plot-lib/plot/private/plot3d/point.rkt | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plot-lib/plot/private/common/parameters.rkt b/plot-lib/plot/private/common/parameters.rkt index 54f6c07a..ebb65753 100644 --- a/plot-lib/plot/private/common/parameters.rkt +++ b/plot-lib/plot/private/common/parameters.rkt @@ -212,9 +212,9 @@ (defparam point-sym Point-Sym 'circle) (defparam point-color Plot-Color 0) -(defparam point-x-jitter Real 0) -(defparam point-y-jitter Real 0) -(defparam point-z-jitter Real 0) +(defparam point-x-jitter Nonnegative-Real 0) +(defparam point-y-jitter Nonnegative-Real 0) +(defparam point-z-jitter Nonnegative-Real 0) (defparam2 point-size Real Nonnegative-Real 6 (nonnegative-rational 'point-size)) (defparam2 point-line-width Real Nonnegative-Real 1 (nonnegative-rational 'point-line-width)) (defparam2 point-alpha Real Nonnegative-Real 1 (unit-ivl 'point-alpha)) diff --git a/plot-lib/plot/private/common/plot-device.rkt b/plot-lib/plot/private/common/plot-device.rkt index 2e0baec5..f2b51287 100644 --- a/plot-lib/plot/private/common/plot-device.rkt +++ b/plot-lib/plot/private/common/plot-device.rkt @@ -651,11 +651,11 @@ (hash-update height i (λ ([v : Exact-Rational]) (max h v)) (λ () 0))))]) (define widths ((inst map Exact-Rational (Pairof Integer Exact-Rational)) - cdr ((inst sort (Pairof Integer Exact-Rational)) + cdr ((inst sort (Pairof Integer Exact-Rational) Integer) (hash->list width) < #:key car))) (define heights ((inst map Exact-Rational (Pairof Integer Exact-Rational)) - cdr ((inst sort (Pairof Integer Exact-Rational)) + cdr ((inst sort (Pairof Integer Exact-Rational) Integer) (hash->list height) < #:key car))) (cond [compact? (values widths heights)] diff --git a/plot-lib/plot/private/plot2d/point.rkt b/plot-lib/plot/private/plot2d/point.rkt index 77cbe82e..a742f039 100644 --- a/plot-lib/plot/private/plot2d/point.rkt +++ b/plot-lib/plot/private/plot2d/point.rkt @@ -71,7 +71,7 @@ [(empty? vs) empty-renderer2d] [else (unless (= 0 x-jitter y-jitter) - (points-apply-jitters vs (vector x-jitter y-jitter) #:ivls (vector (ivl x-min x-max) (ivl y-min y-max)))) + (points-apply-jitters vs ((inst vector Nonnegative-Real) x-jitter y-jitter) #:ivls (vector (ivl x-min x-max) (ivl y-min y-max)))) (match-define (list (vector #{xs : (Listof Real)} #{ys : (Listof Real)}) ...) vs) (let ([x-min (if x-min x-min (apply min* xs))] [x-max (if x-max x-max (apply max* xs))] diff --git a/plot-lib/plot/private/plot3d/point.rkt b/plot-lib/plot/private/plot3d/point.rkt index f80cfc0f..f66286ea 100644 --- a/plot-lib/plot/private/plot3d/point.rkt +++ b/plot-lib/plot/private/plot3d/point.rkt @@ -74,7 +74,7 @@ (cond [(empty? vs) empty-renderer3d] [else (unless (= 0 x-jitter y-jitter z-jitter) - (points-apply-jitters vs (vector x-jitter y-jitter z-jitter) + (points-apply-jitters vs ((inst vector Nonnegative-Real) x-jitter y-jitter z-jitter) #:ivls (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max))))