Skip to content

Commit 24eacab

Browse files
author
Lawrence
committed
Fixed DataPipe not setting Dimensions correctly
DataPipe originally did not account for an initial allocation case, causing errors when appending. This has been resolved.
1 parent 929ba2f commit 24eacab

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

+types/+untyped/DataPipe.m

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,29 @@ function append(obj, data)
213213
rank = length(obj.maxSize);
214214
stride_coords = size(data);
215215
if length(stride_coords) > rank && ~all(stride_coords(rank+1:end) == 1)
216-
warning('Nwb:Types:Untyped:DataPipe:InvalidRank',...
216+
warning('NWB:Types:Untyped:DataPipe:InvalidRank',...
217217
['Expected rank %d not expected for data of size %s. '...
218218
'Data may be lost on write.'],...
219219
rank, mat2str(size(stride_coords)));
220220
end
221+
if length(stride_coords) < rank
222+
new_coords = ones(1, rank);
223+
new_coords(1:length(stride_coords)) = stride_coords;
224+
stride_coords = new_coords;
225+
end
221226
stride_coords = stride_coords(1:rank);
222-
new_extents = fliplr(h5_dims);
223-
new_extents(obj.axis) = obj.offset;
224-
new_extents = new_extents + stride_coords;
227+
228+
if any(0 == h5_dims)
229+
new_extents = stride_coords;
230+
else
231+
new_extents = fliplr(h5_dims);
232+
non_axis_map = true(1, rank);
233+
non_axis_map(obj.axis) = false;
234+
assert(all(stride_coords(non_axis_map) == new_extents(non_axis_map)),...
235+
'NWB:Types:Untyped:DataPipe:InvalidSize',...
236+
'Stride size must match non-axis dimensions.');
237+
new_extents(obj.axis) = obj.offset + stride_coords(obj.axis);
238+
end
225239
h5_extents = fliplr(new_extents);
226240
H5D.set_extent(did, h5_extents);
227241

0 commit comments

Comments
 (0)