mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-03 01:23:31 +01:00
fix(tables): keep text placeholders as values, reset per file, bound scatter labels
- 'none', 'NA' and '-' are empty only in number and date columns; in text columns they are categories. - The table viewer is keyed per file, so a search or filter in one CSV doesn't carry over to the next. - A scatter chart with more than 500 text x values is refused instead of measuring every label (and spreading 100k values into Math.max). - Gist CSV rows are cached per file object instead of a 1 MB string key built on every render. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
37a01257b3
commit
68239afbbb
6 files changed
+44
-14
No files matched your search
@@ -144,7 +144,7 @@ describe("Table analysis", function () {
|
||||
expect(g.header).to.deep.equal(["model", "Rows", "accuracy", "plausible"]);
|
||||
expect(g.body).to.deep.equal([["Baseline", "2", "71.2", "412.0"], ["+ Aug.", "2", "74.0", "447.0"], ["Ours", "2", "78.9", "501.0"]]);
|
||||
// "Treat as number" brings the seed back.
|
||||
expect(T.groupTable(t, all(t), 0, "mean", (c) => true).header).to.deep.equal(["model", "Rows", "seed", "accuracy", "plausible"]);
|
||||
expect(T.groupTable(t, all(t), 0, "mean", () => true).header).to.deep.equal(["model", "Rows", "seed", "accuracy", "plausible"]);
|
||||
expect(g.columns[2].agg).to.equal("mean");
|
||||
expect(g.columns[2].keys[0]).to.be.closeTo(71.2, 1e-9);
|
||||
});
|
||||
@@ -160,6 +160,14 @@ describe("Table analysis", function () {
|
||||
const t = table("k,v\na,1\n,2\na,3\n");
|
||||
expect(T.groupTable(t, all(t), 0, "sum").body).to.deep.equal([["a", "2", "4"], ["(empty)", "1", "2"]]);
|
||||
});
|
||||
it("keeps 'none', 'NA' and '-' as categories in text columns", () => {
|
||||
const t = table("augmentation,acc\nnone,1\nflip,2\nnone,3\nNA,4\n-,5\n,6\n");
|
||||
expect(t.columns[0].type).to.equal("text");
|
||||
expect(t.columns[0].empty).to.equal(1);
|
||||
expect(T.groupTable(t, all(t), 0, "sum").body.map((r) => r[0])).to.deep.equal(["none", "flip", "NA", "-", "(empty)"]);
|
||||
// In a number column they still mean "no value".
|
||||
expect(table("v\n1\nNA\n-\n3\n").columns[0]).to.include({ type: "number", empty: 2 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("export", () => {
|
||||
@@ -216,6 +224,10 @@ describe("Table analysis", function () {
|
||||
expect(line.series[0].path.startsWith("M")).to.equal(true);
|
||||
const scatter = chart.buildChart(t, all(t), { type: "scatter", x: "v", y: ["v"] }, { width: 600 });
|
||||
expect(scatter.series[0].dots).to.have.length(3);
|
||||
// An ID-like text x column is refused instead of measuring every label.
|
||||
const ids = table("id,v\n" + Array.from({ length: 200000 }, (_, i) => `row-${i},${i % 7}`).join("\n"));
|
||||
const many = chart.buildChart(ids, all(ids), { type: "scatter", x: "id", y: ["v"] }, { width: 600 });
|
||||
expect(many.empty).to.match(/200,000 different values/);
|
||||
});
|
||||
it("explains an empty chart", () => {
|
||||
const t = table(RESULTS);
|
||||
|
||||
Reference in new issue
Block a user