Skip to content

Commit 3eb91d6

Browse files
committed
[h5,nc]save: allow plain filename without folder
ci: update actions
1 parent 4cd5743 commit 3eb91d6

File tree

7 files changed

+33
-13
lines changed

7 files changed

+33
-13
lines changed

+stdlib/+hdf5nc/TestHDF5.m

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,17 @@ function test_string(tc, str)
195195
tc.verifyEqual(a, string(str))
196196
end
197197

198-
function test_file_missing(tc)
198+
function test_name_only(tc)
199+
import stdlib.hdf5nc.h5save
200+
201+
[~,name] = fileparts(tempname);
202+
tc.assumeFalse(isfile(name))
199203

200-
[~,badname] = fileparts(tempname);
201-
tc.verifyError(@() stdlib.hdf5nc.h5save(badname,"/bad",0), 'hdf5nc:h5save:fileNotFound')
204+
h5save(name, "/A0", 42);
205+
delete(name)
202206
end
203207

208+
204209
function test_real_only(tc)
205210
import stdlib.hdf5nc.h5save
206211
basic = tc.TestData.basic;

+stdlib/+hdf5nc/TestNetCDF.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,23 @@ function test_rewrite(tc)
157157
tc.verifyEqual(ncread(basic, 'A2'), 3*magic(4))
158158
end
159159

160-
function test_no_char_string(tc)
160+
function test_name_only(tc)
161161
import stdlib.hdf5nc.ncsave
162-
tc.verifyError(@() ncsave(tc.TestData.basic, "/a_string", "hello"), 'MATLAB:validators:mustBeNumeric')
163162

163+
[~,name] = fileparts(tempname);
164+
tc.assumeFalse(isfile(name))
165+
166+
ncsave(name, "/A0", 42);
167+
delete(name)
164168
end
165169

166-
function test_file_missing(tc)
170+
function test_no_char_string(tc)
171+
import stdlib.hdf5nc.ncsave
172+
tc.verifyError(@() ncsave(tc.TestData.basic, "/a_string", "hello"), 'MATLAB:validators:mustBeNumeric')
167173

168-
[~,badname] = fileparts(tempname);
169-
tc.verifyError(@() stdlib.hdf5nc.ncsave(badname,"bad",0), 'hdf5nc:ncsave:fileNotFound')
170174
end
171175

176+
172177
function test_real_only(tc)
173178
import stdlib.hdf5nc.ncsave
174179
basic = tc.TestData.basic;

+stdlib/+hdf5nc/h5save.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function exist_file(filename, varname, A, sizeA)
7373
function new_file(filename, varname, A, sizeA)
7474

7575
folder = fileparts(filename);
76-
if ~isfolder(folder)
76+
if strlength(folder) > 0 && ~isfolder(folder)
7777
error('hdf5nc:h5save:fileNotFound', '%s is not a folder, cannot create %s', folder, filename)
7878
end
7979

+stdlib/+hdf5nc/ncsave.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function exist_file(filename, varname, A, sizeA)
7373
function new_file(filename, varname, A, sizeA, ncdims)
7474

7575
folder = fileparts(filename);
76-
if ~isfolder(folder)
76+
if strlength(folder) > 0 && ~isfolder(folder)
7777
error('hdf5nc:ncsave:fileNotFound', '%s is not a folder, cannot create %s', folder, filename)
7878
end
7979

.github/workflows/ci_matlab.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
- uses: actions/checkout@v2
1616

1717
- name: Install MATLAB
18-
uses: matlab-actions/setup-matlab@v0
18+
uses: matlab-actions/setup-matlab@v1
1919

2020
- name: Run tests and generate artifacts
21-
uses: matlab-actions/run-tests@v0
21+
uses: matlab-actions/run-tests@v1
2222
with:
2323
test-results-junit: test-results/results.xml
2424
code-coverage-cobertura: code-coverage/coverage.xml

CITATION.cff

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cff-version: 1.2.0
2+
message: "If you use this software, please cite it as below."
3+
authors:
4+
- family-names: Hirsch
5+
given-names: Michael
6+
orcid: https://orcid.org/0000-0002-1637-6526
7+
title: Matlab-stdlib
8+
version: 4.1.1
9+
doi: 10.5281/zenodo.3964540
10+
date-released: 2021-11-11

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"downloadUrl": "https://github.com/geospace-code/matlab-stdlib/releases",
99
"issueTracker": "https://github.com/geospace-code/matlab-stdlib/issues",
1010
"name": "matlab-stdlib",
11-
"version": "4.1.0",
11+
"version": "4.1.1",
1212
"identifier": "10.5281/zenodo.3964541",
1313
"description": "Matlab unofficial standard library, including HDF5 / NetCDF4 functions that should be included in Matlab.",
1414
"applicationCategory": "compuation",

0 commit comments

Comments
 (0)