d3.nice(start, stop, 1) returns [-1e308, 1e308] when the interval contains zero, so d3.bin gives NaN bin bounds
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js
- 领域
- data
调研方向
从 src/nice.js 开始。issue指出了反复扩大区间的循环,请追踪计数为 1 且跨越零时,其刻度步长如何变化。使用 node 重现示例,并检查 nice 和 bin 的现有测试。完成的标准是:d3.nice 返回一个覆盖输入的有限区间,且报告的 bin 边界均为有限值。
由索引模型根据 Issue 内容生成。
描述
With count 1 and start < 0 < stop, d3.nice keeps widening the interval until the step overflows. d3.bin hits this through thresholds(1) or when thresholdScott / thresholdFreedmanDiaconis return 1, and the bins get NaN bounds.
import * as d3 from "d3-array";
console.log(d3.nice(-1, 5, 1));
console.log(d3.nice(-0.1, 0.2, 1));
console.log(d3.thresholdScott([-1, 5], -1, 5));
console.log(d3.bin().thresholds(d3.thresholdScott)([-1, 5]));
console.log(d3.bin().thresholds(1)([-1.4, 5.6]));
node t.mjs
Actual:
[ -1e+308, 1e+308 ]
[ -1e+308, 1e+308 ]
1
[ [ -1, 5, x0: -1e+308, x1: NaN ], [ x0: NaN, x1: 1e+308 ] ]
[ [ -1.4, 5.6, x0: -1e+308, x1: NaN ], [ x0: NaN, x1: 1e+308 ] ]
Expected: a finite nice interval covering the input (for example [-10, 10] for d3.nice(-1, 5, 1)), and bins with finite x0 and x1.
Tested with d3-array 3.2.5 from npm and main at 24c015e, Node.js 26.13.0.
The loop in src/nice.js stops only when tickIncrement returns the previous step (or a non-finite one). With count 1 across zero, rounding both ends outward always gives an interval of at least two steps, so every iteration picks the next larger step ([-1, 5] to [-5, 5] to [-10, 10] ...). Stopping when the step grows past the previous one, or capping the iterations as d3-scale's linear.nice does, would end it.
Credit: https://ucsbplse.github.io/
- 主要语言
- JavaScript
- 星标
- 465
- 派生
- 193
- 平均合并
- 5 小时 46 分钟
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
d3/d3-array 的其他 Issue
-
regression: in d3.bin, values next to a threshold go into the wrong bin可能已有人在做 @Fil 于 2 天前认领。 未关闭
d3/d3-array#295 · 1 个 reaction · 已指派 1 人 ·
维护者通常 1 天内回复
-
regression: d3.bin's last bin is twice as wide when the maximum is a threshold可能已有人在做 @Fil 于 2 天前认领。 未关闭
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 35/100
维护者通常 1 天内回复
-
groupSort should use ascendingDefined instead of ascending可能已有人在做 @cpruijsen 于 58 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 10/100
维护者通常 1 天内回复
-
Incorrect results for binary search on large arrays due to miscomputation of midpoint可能已有人在做 @maximilliangrand 于 88 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
d3/d3-array#261 · 11 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
mega-yfue/ha-eufy-sdk-bridge#198 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 78/100
blamechris/chroxy#9108 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
Content:WebExt needs triage
难度 1/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
liberation-data/drivine#733 · 1 条评论 ·
维护者通常 1 天内回复