Skip to content

Commit 1f4b33b

Browse files
committed
simplify
1 parent e6a925e commit 1f4b33b

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

+stdlib/h5save.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ function h5save(filename, varname, A, opts)
4141
try
4242
stdlib.h5save_exist(filename, varname, A, opts.size)
4343
catch e
44-
if ismember(e.identifier, ["MATLAB:imagesci:hdf5io:resourceNotFound", "MATLAB:imagesci:h5info:unableToFind"])
45-
stdlib.h5save_new(filename, varname, A, opts.size, opts.compressLevel)
46-
else
47-
rethrow(e)
44+
switch e.identifier
45+
case {'MATLAB:imagesci:hdf5io:resourceNotFound', 'MATLAB:imagesci:h5info:unableToFind'}
46+
stdlib.h5save_new(filename, varname, A, opts.size, opts.compressLevel)
47+
otherwise
48+
rethrow(e)
4849
end
4950
end
5051

+stdlib/ncexists.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
ncinfo(file, variable);
1919
exists = true;
2020
catch e
21-
if ~strcmp(e.identifier, "MATLAB:imagesci:netcdf:badLocationString") && ...
22-
~strcmp(e.identifier, "MATLAB:imagesci:netcdf:unknownLocation") && ...
23-
~strcmp(e.message, "NetCDF: Variable not found")
21+
if ~any(strcmp(e.identifier, {'MATLAB:imagesci:netcdf:badLocationString', 'MATLAB:imagesci:netcdf:unknownLocation'})) && ...
22+
strcmp(e.message, {'NetCDF: Variable not found'})
2423

2524
rethrow(e)
2625
end

+stdlib/ncsave.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ function ncsave(filename, varname, A, opts)
4444
try
4545
stdlib.ncsave_exist(filename, varname, A, sizeA)
4646
catch e
47-
if ismember(e.identifier, ["MATLAB:imagesci:netcdf:unableToOpenFileforRead", "MATLAB:imagesci:netcdf:unknownLocation"])
48-
stdlib.ncsave_new(filename, varname, A, sizeA, opts.dims, opts.compressLevel)
49-
else
50-
rethrow(e)
47+
switch e.identifier
48+
case {'MATLAB:imagesci:netcdf:unableToOpenFileforRead', 'MATLAB:imagesci:netcdf:unknownLocation'}
49+
stdlib.ncsave_new(filename, varname, A, sizeA, opts.dims, opts.compressLevel)
50+
otherwise, rethrow(e)
5151
end
5252
end
5353

0 commit comments

Comments
 (0)