Make d3.autoType the default row accessor.
mbostock opened this issue · comments
This will require a major version bump, but I think it’d be good to make d3.autoType the default row accessor for dsv.parse and dsv.parseRows. If you want to disable automatic type inference, you can pass the identity function (d => d
) as the row function.
Yes!
I'm not totally sure of the consequences here, isn't it that we can now inline objectConverter?
I simply added f=autoType to parse and parseRows, and got 77 test failing 😱 — I started to go through them, but for so many of them, I'm at a loss whether we want to change them or keep the old test with f=null
or f = identity
.
Examples:
tape("csvParse(string) does not strip whitespace", function(test) {
test.deepEqual(dsv.csvParse("a,b,c\n 1, 2 ,3 "), table([{a: " 1", b: " 2 ", c: "3 "}], ["a", "b", "c"]));
test.end();
});
autoType returns numbers 1, 2, 3.
We could amend the test to "csvParse(string, null) does not strip whitespace"; or test that we get 1, 2, 3. (There is an autoType test saying it should return a number.)
tape("csvParse(string) treats empty fields as the empty string", function(test) {
test.deepEqual(dsv.csvParse("a,b,c\n1,,3"), table([{a: 1, b: "", c: 3}], ["a", "b", "c"]));
test.end();
});
autoType returns b:null
etc.
I’m not inclined to change this behavior for d3 v6, because even though it might be nice, it’s a pretty significant backwards-incompatibility shift.
I’m inclined to keep the status quo for the foreseeable future.