Skip to content

Commit 4043432

Browse files
committed
coerce_ds: float32=>single, float64=>double
1 parent e67dcc0 commit 4043432

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

+stdlib/+hdf5nc/private/coerce_ds.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414
return
1515
end
1616

17+
if dtype == "float64"
18+
dtype = "double";
19+
elseif dtype == "float32"
20+
dtype = "single";
21+
end
22+
1723
switch dtype
1824
case ""
1925
return
20-
case {'float64', 'double', 'float32', 'single', 'int8', 'int16', 'int32', 'int64','uint8', 'uint16', 'uint32', 'uint64'}
26+
case {'double', 'single', 'int8', 'int16', 'int32', 'int64','uint8', 'uint16', 'uint32', 'uint64'}
2127
A = cast(A, dtype);
2228
case 'char'
2329
A = string(A);

+stdlib/TestHDF5.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
end
66

77
properties (TestParameter)
8-
type = {'single', 'double', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64'}
8+
type = {'single', 'double', 'float32', 'float64', ...
9+
'int8', 'int16', 'int32', 'int64', ...
10+
'uint8', 'uint16', 'uint32', 'uint64'}
911
vars = {'A0', 'A1', 'A2', 'A3', 'A4'}
1012
str = {"string", 'char'}
1113
end
@@ -224,7 +226,15 @@ function test_coerce(tc, type)
224226

225227
tc.assumeThat(basic, IsFile)
226228

227-
tc.verifyClass(h5read(basic, vn), type)
229+
if type == "float32"
230+
vtype = "single";
231+
elseif type == "float64"
232+
vtype = "double";
233+
else
234+
vtype = type;
235+
end
236+
237+
tc.verifyClass(h5read(basic, vn), vtype)
228238
end
229239

230240

0 commit comments

Comments
 (0)