Editorial diagram design for Claude Code, Codex, GitHub Copilot, Cursor, Factory Droid, Qoder, and Pi. 45 diagram types. Self-contained HTML + SVG. No shadows. No Mermaid slop.
fix(dumbbell): keep finite extreme domains and coordinates (#365)
Rudy Mizrahi Celeklid54f331e2bee
diff --git a/scripts/test-verify-dumbbell.py b/scripts/test-verify-dumbbell.pyindex 82dc428..1541549 100644--- a/scripts/test-verify-dumbbell.py+++ b/scripts/test-verify-dumbbell.py@@ -71,6 +71,21 @@ def test_all_zero_is_finite():"all-zero data puts every dot on the floor, which is the truth")+def test_finite_extremes_scale_without_overflow():+ for values in ([5e-324], [1.7e308], [-1.7e308, 1.7e308]):+ floor, ceiling = resolve_domain(values)+ ok(math.isfinite(floor) and math.isfinite(ceiling),+ "finite extreme values resolve finite axis bounds")+ coordinates = [scale(value, floor, ceiling) for value in values]+ ok(all(math.isfinite(value) for value in coordinates),+ "finite extreme values scale without overflow")+ ok(all(verify_dumbbell.PLOT_X0 <= value <= verify_dumbbell.PLOT_X0 + verify_dumbbell.PLOT_WIDTH+ for value in coordinates), "extreme values remain inside the plot")+ if len(values) == 2:+ ok(coordinates == [verify_dumbbell.PLOT_X0, verify_dumbbell.PLOT_X0 + verify_dumbbell.PLOT_WIDTH],+ "opposite extreme endpoints retain the whole plot width")++def test_zero_touching_domains():floor, ceiling = resolve_domain([0, 5, 12])ok((floor, ceiling) == (0.0, 20.0),@@ -199,6 +214,7 @@ def main() -> int:import tempfiletest_all_zero_is_finite()+ test_finite_extremes_scale_without_overflow()test_zero_touching_domains()test_sign_cases_resolve()test_identical_and_tiny_values()diff --git a/scripts/verify-dumbbell.py b/scripts/verify-dumbbell.pyindex 7d1b2c9..59c816a 100644--- a/scripts/verify-dumbbell.py+++ b/scripts/verify-dumbbell.py@@ -89,12 +89,16 @@ def _nice_magnitude(value: float) -> float:return 0.0exponent = math.floor(math.log10(magnitude))base = 10.0 ** exponent+ if base == 0.0:+ # The next representable subnormal is already the smallest safe bound.+ return magnitudefor step in (1.0, 2.0, 2.5, 5.0, 10.0):candidate = step * base# Bounds must enclose the data even when its unit is much smaller# than a fixed epsilon. The ladder already provides outward rounding.if candidate >= magnitude:- return candidate+ # A finite input must not gain an infinite bound from the ladder.+ return candidate if math.isfinite(candidate) else magnitudereturn 10.0 * base@@ -134,7 +138,12 @@ def scale(value: float, floor: float, ceiling: float) -> float:span = ceiling - floorif span <= 0:raise DomainError("non-positive span %r" % (span,))- return PLOT_X0 + (float(value) - floor) / span * PLOT_WIDTH+ if math.isinf(span):+ # Halving first avoids overflow when finite bounds have opposite signs.+ ratio = (float(value) / 2 - floor / 2) / (ceiling / 2 - floor / 2)+ else:+ ratio = (float(value) - floor) / span+ return PLOT_X0 + ratio * PLOT_WIDTHdef is_truncated(values, floor: float, ceiling: float) -> bool:diff --git a/skills/diagram-design/references/type-bar.md b/skills/diagram-design/references/type-bar.mdindex 07f59d0..3654304 100644--- a/skills/diagram-design/references/type-bar.md+++ b/skills/diagram-design/references/type-bar.md@@ -104,3 +104,5 @@ Two of these rules live in a formula rather than a drawing, so they are executab- `assets/example-bar.html` — minimal light- `assets/example-bar-dark.html` — minimal dark- `assets/example-bar-full.html` — full editorial++Dumbbell domain resolution retains finite bounds for representable subnormal and extreme values. If the next nice ladder step would overflow, the finite extreme is used; opposite-sign extreme domains are scaled without overflowing their span.