window transform: difference, ratio, first and last drop the trailing outputs of each series
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 88/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js
调研方向
阅读 src/transforms/window.js 并检查 reduceDifference、reduceRatio、reduceFirst 和 reduceLast,将它们在 strict 和 non-strict 模式下的循环边界与示例中描述的行为进行比较。为两种模式下的末尾输出添加或更新测试,然后运行相关的 window transform 测试。当这些 reducer 生成预期的完整长度输出(包括 strict 为 false 时被截短的末尾窗口)时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
The difference, ratio, first and last window reducers stop their loops early: with strict: true the last full window is missing, and with strict: false the last k - 1 - s truncated windows are missing. Other reducers such as mean fill these positions.
import * as Plot from "@observablehq/plot";
const run = (w, data) => {
const o = Plot.windowY(w, {x: "i", y: "v"});
o.transform(data, [Uint32Array.from(data, (_, i) => i)]);
return Array.from(o.y.transform());
};
const d = [2, 4, 8, 16].map((v, i) => ({i, v}));
console.log(run({k: 2, reduce: "difference", strict: true, anchor: "end"}, d));
console.log(run({k: 2, reduce: "ratio", strict: true, anchor: "end"}, d));
console.log(run({k: 1, reduce: "last", strict: true}, d));
console.log(run({k: 3, reduce: "first", anchor: "start"}, d));
console.log(run({k: 3, reduce: "difference", anchor: "start"}, d));
console.log(run({k: 3, reduce: "mean", anchor: "start"}, d));
node t.mjs
Actual:
[ undefined, 2, 4, undefined ]
[ undefined, 2, 2, undefined ]
[ 2, 4, 8, undefined ]
[ 2, 4, undefined, undefined ]
[ 6, 12, undefined, undefined ]
[ 4.666666666666667, 9.333333333333334, 12, 16 ]
Expected:
[ undefined, 2, 4, 8 ]
[ undefined, 2, 2, 2 ]
[ 2, 4, 8, 16 ]
[ 2, 4, 8, 16 ]
[ 6, 12, 8, 0 ]
[ 4.666666666666667, 9.333333333333334, 12, 16 ]
In a chart, Plot.lineY(data, Plot.windowY({k: 7, reduce: "difference"}, ...)) stops short of the right edge.
Tested with @observablehq/plot 0.6.19 and main 2245188, Node.js v26.13.0.
In src/transforms/window.js, reduceDifference, reduceRatio, reduceFirst and reduceLast use n = I.length - k in the strict branch (should be I.length - k + 1) and n = I.length - k + s + 1 in the non-strict branch (should be I.length - s, with the window clipped to I.length).
Credit: https://ucsbplse.github.io/
- 主要语言
- HTML
- 星标
- 5.4k
- 派生
- 251
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
observablehq/plot 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
observablehq/plot#2471 ·
-
[Types] Wrong recursion in Mark’s _tip_ option可能重新可做 关联的 PR 已关闭且未合并。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
observablehq/plot#2459 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 68/100
observablehq/plot#2453 ·
-
难度 1/5 1 小时以内 新手友好度 85/100
observablehq/plot#2447 · 2 条评论 ·
-
Channel documentation with a section describing z可能重新可做 @LeonxLJX 于 67 天前认领,目前没有进行中的 PR。 未关闭documentation
难度 2/5 1-3 小时 新手友好度 72/100
observablehq/plot#1533 · 3 条评论 · 1 个 reaction ·
查看 observablehq/plot 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 73/100
bgreenwell/pdp#140 · 1 条评论 · 1 个 reaction ·
-
bin: stop can round 1 ulp below extent[1], so the maximum value is binned as +Infinity and dropped未关闭
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
Numeric tick formatter gives repeated labels in scientific notation and with bounds: 'data'可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug data order-flow studies
难度 2/5 1-3 小时 新手友好度 88/100
userFRM/egui-charts#2530 ·
维护者通常 1 天内回复
-
Analysis Functions bug
难度 2/5 1-3 小时 新手友好度 67/100
AllenInstitute/MIES#2856 ·
维护者通常 1 天内回复