Skip to content

Commit

Permalink
Actually test compound references
Browse files Browse the repository at this point in the history
Was originally missing any validation outside of IO.
Now verifies that the read-in data is the same as the written.

Minor change to RegionViews and ObjectViews using arrays instead of
cell arrays.
  • Loading branch information
Lawrence committed Jun 14, 2021
1 parent 8971627 commit dbedf05
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions +io/getRefData.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
did = H5D.open(fid, refpaths{i});
sid = H5D.get_space(did);
%by default, we use block mode.
regionShapes = ref.region;
for j = 1:length(ref.region)
regionShapes = ref(i).region;
for j = 1:length(regionShapes)
regionShapes{j} = io.space.findShapes(regionShapes{j});
end
refspace(i) = io.space.getReadSpace(regionShapes, sid);
Expand Down
2 changes: 1 addition & 1 deletion +io/parseCompound.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
r = refdata(:,k);
reflist{k} = io.parseReference(did, reftids{j}, r);
end
data.(rpname) = reflist;
data.(rpname) = [reflist{:}] .';
end
end

Expand Down
13 changes: 7 additions & 6 deletions +tests/+unit/dataStubTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,16 @@ function testObjectCopy(testCase)
rcPath = '/acquisition/rc';
rcDataPath = [rcPath '/data'];
rcRef = types.cs.CompoundRefData('data', table(...
rand(),...
rand(),...
types.untyped.ObjectView(rcPath),...
types.untyped.RegionView(rcDataPath, 1:2, 99:100),...
rand(2, 1),...
rand(2, 1),...
[types.untyped.ObjectView(rcPath); types.untyped.ObjectView(rcPath)],...
[types.untyped.RegionView(rcDataPath, 1:2, 99:100); types.untyped.RegionView(rcDataPath, 5:6, 88:89)],...
'VariableNames', {'a', 'b', 'objref', 'regref'}));

nwb.acquisition.set('rc', rc);
nwb.analysis.set('rcRef', rcRef);
nwbExport(nwb, 'original.nwb');
nwb = nwbRead('original.nwb');
nwbExport(nwb, 'new.nwb');
nwbNew = nwbRead('original.nwb');
tests.util.verifyContainerEqual(testCase, nwbNew, nwb);
nwbExport(nwbNew, 'new.nwb');
end

0 comments on commit dbedf05

Please sign in to comment.