The goal of this PR is to test the low-level H5WasmApi class — more specifically, the metadata and values it returns for HDF5 datasets with various types and shapes.
To do so, I've written a Python script (inspired from silx' script) to generate a sample HDF5 file with h5py. In this file, I try to generate HDF5 datasets of as many kinds as I can (H5T_INTEGER, H5T_COMPOUND, etc.) and with as many interesting dtype combinations as I can think of (int8, complex64, etc.).
The idea is to be able to test:
that h5wasm returns the values as accurately as possible (without loss of precision, type coercion, etc.);
that h5wasm returns the metadata as accurately as possible (with all the information we need to parse it correctly);
that H5WasmApi doesn't interfere with the values in unwanted ways;
that H5WasmApi creates our internal DType objects from the raw metadata accurately.
More specifically, this test will help identify:
values that are clamped/rounded/unsupported by h5wasm and/or H5Web;
dtypes that are currently unknown/unsupported by h5wasm and/or H5Web;
inconsistencies between data providers in the values/metadata they provide;
inaccuracies in the way we generate mock data for testing purposes.
I purposely did not to add any attributes to the sample file, as they didn't seem to add any testing value (the dtype parsing is the same, and h5wasm reads/processes datasets and attributes values the same way ... I hope). I also did not add groups, links, datatypes, and NeXus/RGB/scatter data as this falls out of the scope of what I'm wanting to test (at least for the moment).
The test itself consists in a single, very basic snapshot test:
I start by loading the sample file, initialising the API and calling api.getEntity('/') to get the metadata of the root group and its children;
Then, for each child dataset, I get the metadata I'm interested in and request the dataset's value with api.getValue({ dataset }). (I've kept the sample file flat to keep this test code as concise as possible.)
Finally, I take a snapshot of this array of dataset metadata+values. If the snapshot matches the existing, committed snapshot, then the test passes; otherwise it fails.
The goal of this PR is to test the low-level
H5WasmApi
class — more specifically, the metadata and values it returns for HDF5 datasets with various types and shapes.To do so, I've written a Python script (inspired from silx' script) to generate a sample HDF5 file with h5py. In this file, I try to generate HDF5 datasets of as many kinds as I can (
H5T_INTEGER
,H5T_COMPOUND
, etc.) and with as many interesting dtype combinations as I can think of (int8
,complex64
, etc.).The idea is to be able to test:
H5WasmApi
doesn't interfere with the values in unwanted ways;H5WasmApi
creates our internalDType
objects from the raw metadata accurately.More specifically, this test will help identify:
You can explore the sample file here: https://h5web.panosc.eu/h5wasm?url=https%3A%2F%2Fwww.silx.org%2Fpub%2Fh5web%2Fsample.h5
The test itself consists in a single, very basic snapshot test:
api.getEntity('/')
to get the metadata of the root group and its children;api.getValue({ dataset })
. (I've kept the sample file flat to keep this test code as concise as possible.)