plot icon indicating copy to clipboard operation
plot copied to clipboard

add BigInt support to the normalize transform

Open Fil opened this issue 1 year ago • 2 comments

Note: it's a bit of a bummer in that we're adding overhead for all Arrays (by making a copy of the channel to a Float64Array). Maybe we could just do it if the first non-nullish value is BigInt?

cc: @juba

closes #2154

Fil avatar Aug 28 '24 13:08 Fil

It should definitely be earlier — in my code we coerce the whole channel as many times as there are series. But where? Maybe as high as in the map transform, where we do https://github.com/observablehq/plot/blob/0032c11160e6340ce44307675d93bed382d10446/src/transforms/map.js#L36

In that case the mapper should possibly have a type key, like so:

  {
    mapIndex(I, S, T) {
      const b = basis(I, S);
      for (const i of I) {
        T[i] = S[i] === null ? NaN : S[i] / b;
      }
    },
    type: Float64Array
  }

that would be passed as the third argument to valueof?

The alternative is (what you say) to preemptively convert all BigInt independently of where they're used.

Fil avatar Aug 28 '24 16:08 Fil

This is very close to https://github.com/observablehq/plot/issues/473

Fil avatar Sep 09 '24 14:09 Fil