Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add BigInt support to the normalize transform #2155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Aug 28, 2024

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

Copy link
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we fix this earlier, perhaps by having maybeTypedArrowify always coerce array of BigInt back to Number? Or is it Plot’s responsibility to undo BigInt’s strict coercion wherever BigInt may occur?

@Fil
Copy link
Contributor Author

Fil commented Aug 28, 2024

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

const X = channels.map(({input}) => valueof(data, input));

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
Copy link
Contributor Author

Fil commented Sep 9, 2024

This is very close to #473

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when normalizing a BigInt variable
2 participants