silx-kit / jupyterlab-h5web

A JupyterLab extension to explore and visualize HDF5 file contents. Based on https://github.com/silx-kit/h5web.
MIT License
65 stars 8 forks source link

Fix wrong encoding/decoding of big endians #111

Closed loichuder closed 1 year ago

loichuder commented 1 year ago

Fix https://github.com/silx-kit/h5web/issues/1421#issuecomment-1515811198

When sending the data as binary, the blob is directly fed into a TypedArray in the JS part. Apparently, this only works if the original data was in little-endian order before encoding to binary.

In the h5grove demo, each time we fetch data in binary format, we make sure that the data can be correctly decoded by using the query parameter dtype=safe:

  1. It makes sure that it has a dtype that has equivalent in JS
  2. and that is is in little-endian order

(see https://github.com/silx-kit/h5grove/blob/5b71298493ef180c4202bb2179cddd90316fb82d/h5grove/utils.py#L129 for the relevant method)

In the JupyterLab ext, I forgot to parse the dtype parameter so that this condition wasn't respected for big-endians. This PR fixes this.

loichuder commented 1 year ago

attn @t20100