Skip to content

Commit c3f0dfe

Browse files
committed
fix: validate log/sqrt scale limits
1 parent 1fa4d11 commit c3f0dfe

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/scale/train.typ

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,18 @@
338338
) {
339339
// User-supplied limits come in data space; lift them to stat space.
340340
let (lo, hi) = domain
341+
if transform == "log10" {
342+
assert(
343+
lo > 0 and hi > 0,
344+
message: "log10 scale limits must be positive; got " + repr((lo, hi)),
345+
)
346+
} else if transform == "sqrt" {
347+
assert(
348+
lo >= 0 and hi >= 0,
349+
message: "sqrt scale limits must be non-negative; got "
350+
+ repr((lo, hi)),
351+
)
352+
}
341353
domain = (transform-fwd(transform, lo), transform-fwd(transform, hi))
342354
}
343355
let level-index = if scale-type == "discrete" {

0 commit comments

Comments
 (0)