From a88c2e134f08b609416948aa9dc3f0a27943cb66 Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Sun, 26 Nov 2023 23:38:56 -0500 Subject: [PATCH] scalar and variablelengthstring can not use with deflate on --- loadh5.m | 1 + saveh5.m | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/loadh5.m b/loadh5.m index 98c5976..048b07c 100644 --- a/loadh5.m +++ b/loadh5.m @@ -52,6 +52,7 @@ % path = ''; +opt = struct; if (bitand(length(varargin), 1) == 0) opt = varargin2struct(varargin{:}); elseif (length(varargin) >= 3) diff --git a/saveh5.m b/saveh5.m index 32a73fc..ff62493 100644 --- a/saveh5.m +++ b/saveh5.m @@ -264,6 +264,8 @@ function saveh5(data, fname, varargin) h5_chunk_dims = fliplr(chunksize); H5P.set_chunk(pd, h5_chunk_dims); H5P.set_deflate(pd, complevel); + opt.scalar = 0; + opt.variablelengthstring = 0; else error('Filter %s is unsupported', usefilter); end @@ -293,7 +295,7 @@ function saveh5(data, fname, varargin) if (isa(item, 'string') && length(item) > 1) itemsize = H5S.create_simple(ndims(item), fliplr(size(item)), fliplr(size(item))); end - elseif (isnumeric(item) && numel(item) == 1 && forcedim == 0 && ndims(item) == 2 && opt.scalar) + elseif (isnumeric(item) && numel(item) == 1 && ndims(item) == 2 && opt.scalar) itemsize = H5S.create('H5S_SCALAR'); else itemsize = H5S.create_simple(ndims(item), fliplr(size(item)), fliplr(size(item)));