-
Notifications
You must be signed in to change notification settings - Fork 19
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
64-bit integers not shown correctly in h5web display #1679
Comments
Indeed, big integers (int/uint64) numbers are not currently supported. They get converted to primitive JS numbers (float64) to avoid errors, which is why you're seeing inaccurate values. We would definitely like to improve support for big integers, though, so we'll use this issue to report any progress. Thanks! |
ScopeThe scope of this issue is to make bigints (as in primitive JS The scope does not include maintaining bigint precision in any of the WebGL-based visualizations like Heatmap, Line, RGB, and the NeXus visualizations, or showing exact bigint values in the tooltips of these visualizations. ChallengesTyping
This means that if, in some parts of the codebase, we end up with the union type This mostly comes down to the Provider supportNot all providers will be able to provide all (u)int-64 values as primitive or typed bigints, at least not in the short term. For instance, h5grove currently sends compound dataset values as JSON, so bigints end up as primitive numbers (i.e. This is a similar problem to booleans, which some providers send as primitive booleans while others send as numbers (0/1). If we can't distinguish the two cases, we have no choice but to type values as Working solutionI have a working solution that consists in introducing a new It then becomes possible to add conditions in
Obviously this is just the tip of the iceberg; the full solution required making changes to 46 files. The problem is that it feels like I'm fighting with our own types a bit. It also gets super confusing in terms of naming throughout the codebase, since for it to work, Generic solutionThe piece of the puzzle I unlocked by working on I'm thinking that we can expand the For instance, h5grove would be able to announce that it would return a I really like this solution because:
Now let's see if I can make it work. |
This issue should be fixed once the PRs above are merged. It took a lot of clean-up and refactoring to get there, but the final implementation is quite seamless — I didn't need the Providers can now choose to return int-64 values as numbers or bigints (whether primitive or typed). Both h5grove and h5wasm do so in most cases. The only limitation currently is when h5grove has to serialise values to JSON, like with compound and vlen datasets: since JSON doesn't support bigints, they still get cast to float-64 JS numbers as before. When bigints are returned, they are displayed with exact precision in the Scalar, Matrix and Compound visualizations (unless the "scientific" notation is selected in the toolbar). With WebGL-based visualizations, like Line and Heatmap, all bigints are converted to numbers before reaching the visualizations. We may be able to avoid some conversions in the future, for instance to show exact values in the tooltips, but only if there's a strong user needs for that. |
Describe the bug
64-bit signed and unsigned integers are not always displayed correctly in the h5web display window.
To Reproduce
int64_scalar
datasetDisplay
view on the right panel-9223372036854776000
Expected behaviour
The value returned by
h5dump -d int64_scalar sample.h5
is:-9223372036854775808
Similar happens with uint64:
uint64_scalar datatype as shown on h5web window:
18446744073709552000
while h5dump reports:
18446744073709551615
Context
The text was updated successfully, but these errors were encountered: