From df2348afff87e4ddac1facfa044d83ab9bcaf291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Wed, 27 May 2026 19:19:50 +0200 Subject: [PATCH 1/2] fix: reject non-positive bins --- src/utils/bin.typ | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/bin.typ b/src/utils/bin.typ index c6f73af4..346e025c 100644 --- a/src/utils/bin.typ +++ b/src/utils/bin.typ @@ -21,6 +21,10 @@ let n-bins = if binwidth != none and binwidth > 0 { calc.max(1, int(calc.ceil((hi - lo) / binwidth))) } else { + assert( + bins != none and bins > 0, + message: "bins must be a positive integer; got " + repr(bins), + ) bins } (n-bins: n-bins, width: (hi - lo) / n-bins) From dcb7308929f6a036fd0d436cd377b522a724056b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Wed, 27 May 2026 20:34:55 +0200 Subject: [PATCH 2/2] docs: changelog for bins validation --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a988f104..55dbf367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - feat: `labs()` fields default to `auto`; pass `none` to suppress an axis or legend title and reclaim the space it reserved. (#12) - feat: `element-blank()` on a text surface (axis, plot, or legend title) collapses the space the text would reserve. (#12) - feat: `width`/`height` accept `auto` to fill the available space of a bounded container. (#10) +- fix: binning geoms reject a non-positive `bins` with a clear error instead of dividing by zero. (#38) - fix: contour stats skip incomplete cells when the `(x, y, z)` grid is sparse instead of panicking. (#37) - fix: `scale-*-manual()` with an empty `values` array reports a clear error instead of an opaque divide-by-zero. (#36) - fix: number formatters carry a fraction that rounds up to a whole unit (e.g., `0.9999995` no longer renders as `0.1`), and `format-scientific` keeps its mantissa in `[1, 10)`. (#35)