Skip to content

Commit 7355fa8

Browse files
committed
h5exists: simplify
1 parent dd72713 commit 7355fa8

File tree

5 files changed

+7
-18
lines changed

5 files changed

+7
-18
lines changed

+stdlib/+hdf5nc/h5exists.m

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,11 @@
22

33
arguments
44
file (1,1) string {mustBeFile}
5-
variable string {mustBeScalarOrEmpty}
5+
variable (1,1) string
66
end
77

88
exists = false;
99

10-
if(strlength(variable) == 0)
11-
return
12-
end
13-
14-
if ~startsWith(variable, "/")
15-
variable = "/" + variable;
16-
end
17-
1810
try
1911
h5info(file, variable);
2012
exists = true;

+stdlib/+hdf5nc/ncexists.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
arguments
44
file (1,1) string {mustBeFile}
5-
variable string {mustBeScalarOrEmpty}
5+
variable (1,1) string
66
end
77

88
exists = false;

+stdlib/h5exists.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
arguments
1313
file (1,1) string
14-
variable string {mustBeScalarOrEmpty}
14+
variable (1,1) string
1515
end
1616

1717
exists = stdlib.hdf5nc.h5exists(file, variable);

+stdlib/ncexists.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
arguments
1313
file (1,1) string
14-
variable string {mustBeScalarOrEmpty}
14+
variable (1,1) string
1515
end
1616

1717
exists = stdlib.hdf5nc.ncexists(file, variable);

test/TestHDF5.m

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,10 @@ function test_exists(tc)
9797
import matlab.unittest.constraints.IsScalar
9898
basic = tc.TestData.basic;
9999

100-
e = stdlib.h5exists(basic, "");
100+
e = stdlib.h5exists(basic, "/A0");
101101

102102
tc.verifyThat(e, IsScalar)
103-
tc.verifyFalse(e)
104-
105-
tc.verifyTrue(stdlib.h5exists(basic, "/A0"));
106-
tc.verifyTrue(stdlib.h5exists(basic, "A0"));
103+
tc.verifyTrue(e);
107104

108105
end
109106

@@ -194,7 +191,7 @@ function test_shape(tc)
194191
function test_coerce(tc, type)
195192
basic = tc.TestData.basic;
196193

197-
stdlib.h5save(basic, type, 0, "type",type)
194+
stdlib.h5save(basic, "/"+type, 0, "type",type)
198195

199196
switch type
200197
case "string", vt = 'char';

0 commit comments

Comments
 (0)