Skip to content

Commit bc7e5fd

Browse files
committed
use string.empty
1 parent d349f62 commit bc7e5fd

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

+hdf5nc/coerce_ds.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
function A = coerce_ds(A, dtype)
22
% used by h5save and ncsave
33
arguments
4-
A {mustBeNonempty}
5-
dtype (1,1) string
4+
A {mustBeNumeric,mustBeNonempty}
5+
dtype string
66
end
77

8+
if isempty(dtype)
9+
return
10+
end
11+
12+
assert(isscalar(dtype), "dtype must be scalar")
13+
814
switch dtype
915
case ""
1016
return

+hdf5nc/h5save.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function h5save(filename, varname, A, opts)
77
varname (1,1) string
88
A {mustBeNumeric,mustBeNonempty}
99
opts.size (1,:) {mustBeInteger,mustBeNonnegative} = []
10-
opts.type (1,1) string = ""
10+
opts.type string = string.empty
1111
end
1212

1313
filename = hdf5nc.expanduser(filename);
@@ -23,7 +23,6 @@ function h5save(filename, varname, A, opts)
2323
end
2424
% coerce if needed
2525
A = hdf5nc.coerce_ds(A, opts.type);
26-
2726
if ischar(A)
2827
A = string(A);
2928
sizeA = size(A);
@@ -80,7 +79,6 @@ function new_file(filename, varname, A, sizeA)
8079

8180
end % function
8281

83-
8482
% Copyright 2020 Michael Hirsch, Ph.D.
8583

8684
% Licensed under the Apache License, Version 2.0 (the "License");

+hdf5nc/h5variables.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
% get dataset names and groups in an HDF5 file
33
arguments
44
filename (1,1) string
5-
group (1,1) string = ""
5+
group string = string.empty
66
end
77

8-
names = string([]);
9-
groups = string([]);
8+
names = string.empty;
9+
groups = string.empty;
1010

1111
finf = h5info(hdf5nc.expanduser(filename));
1212
ds = finf.Datasets;
1313
if isempty(ds)
1414
return
1515
end
1616

17-
if group ~= ""
17+
if ~isempty(group)
1818
gs = finf.Groups;
1919
i = string({gs(:).Name}) == group;
2020
if ~any(i)

+hdf5nc/ncsave.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function ncsave(filename, varname, A, opts)
77
varname (1,1) string
88
A {mustBeNumeric,mustBeNonempty}
99
opts.dims cell = {}
10-
opts.type (1,1) string = ""
10+
opts.type string = string.empty
1111
end
1212

1313
filename = hdf5nc.expanduser(filename);

0 commit comments

Comments
 (0)