From ba68a6649355f333e18e4c3b22398b0f3844c089 Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Mon, 22 Apr 2024 13:33:49 +0200 Subject: [PATCH] Add `strpad` to string dtype metadata --- README.md | 1 - src/hdf5_util.cc | 5 +---- src/hdf5_util_helpers.d.ts | 3 ++- test/bool_test.mjs | 1 - test/compound_and_array_test.mjs | 5 +---- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 77641f7..96fbd14 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,6 @@ data.metadata /* { "signed": true, - "cset": -1, "vlen": false, "littleEndian": true, "type": 0, diff --git a/src/hdf5_util.cc b/src/hdf5_util.cc index 1d62227..c830efd 100644 --- a/src/hdf5_util.cc +++ b/src/hdf5_util.cc @@ -261,10 +261,7 @@ val get_dtype_metadata(hid_t dtype) if (dtype_class == H5T_STRING) { attr.set("cset", (int)(H5Tget_cset(dtype))); - } - else - { - attr.set("cset", -1); + attr.set("strpad", (int)(H5Tget_strpad(dtype))); } if (dtype_class == H5T_COMPOUND) diff --git a/src/hdf5_util_helpers.d.ts b/src/hdf5_util_helpers.d.ts index f41ab77..b19c081 100644 --- a/src/hdf5_util_helpers.d.ts +++ b/src/hdf5_util_helpers.d.ts @@ -21,7 +21,7 @@ export interface Metadata { array_type?: Metadata, chunks: number[] | null, compound_type?: CompoundTypeMetadata, - cset: number, + cset?: number, enum_type?: EnumTypeMetadata, littleEndian: boolean, maxshape: number[] | null, @@ -29,6 +29,7 @@ export interface Metadata { shape: number[] | null, signed: boolean, size: number, + strpad?: number, total_size: number, type: number, vlen: boolean, diff --git a/test/bool_test.mjs b/test/bool_test.mjs index 0dd2bf5..ef27ba6 100644 --- a/test/bool_test.mjs +++ b/test/bool_test.mjs @@ -14,7 +14,6 @@ async function bool_test() { assert.deepEqual(f.get('bool').metadata, { chunks: null, - cset: -1, enum_type: { type: 0, nmembers: 2, diff --git a/test/compound_and_array_test.mjs b/test/compound_and_array_test.mjs index cdab848..c728531 100644 --- a/test/compound_and_array_test.mjs +++ b/test/compound_and_array_test.mjs @@ -67,7 +67,6 @@ async function compound_array_test() { members: [ { array_type: { - cset: -1, shape: [2, 2], littleEndian: true, signed: false, @@ -76,7 +75,6 @@ async function compound_array_test() { type: 1, vlen: false, }, - cset: -1, littleEndian: true, name: 'floaty', offset: 0, @@ -93,11 +91,11 @@ async function compound_array_test() { littleEndian: false, signed: false, size: 5, + strpad: 1, total_size: 4, type: 3, vlen: false, }, - cset: -1, littleEndian: false, name: 'stringy', offset: 32, @@ -110,7 +108,6 @@ async function compound_array_test() { ], nmembers: 2 }, - cset: -1, littleEndian: true, maxshape: [2], shape: [2],