Skip to content

Commit

Permalink
Fixed DataPipe not setting Dimensions correctly
Browse files Browse the repository at this point in the history
DataPipe originally did not account for an initial allocation case, causing
errors when appending.

This has been resolved.
  • Loading branch information
Lawrence committed Mar 4, 2020
1 parent 929ba2f commit 24eacab
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions +types/+untyped/DataPipe.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,29 @@ function append(obj, data)
rank = length(obj.maxSize);
stride_coords = size(data);
if length(stride_coords) > rank && ~all(stride_coords(rank+1:end) == 1)
warning('Nwb:Types:Untyped:DataPipe:InvalidRank',...
warning('NWB:Types:Untyped:DataPipe:InvalidRank',...
['Expected rank %d not expected for data of size %s. '...
'Data may be lost on write.'],...
rank, mat2str(size(stride_coords)));
end
if length(stride_coords) < rank
new_coords = ones(1, rank);
new_coords(1:length(stride_coords)) = stride_coords;
stride_coords = new_coords;
end
stride_coords = stride_coords(1:rank);
new_extents = fliplr(h5_dims);
new_extents(obj.axis) = obj.offset;
new_extents = new_extents + stride_coords;

if any(0 == h5_dims)
new_extents = stride_coords;
else
new_extents = fliplr(h5_dims);
non_axis_map = true(1, rank);
non_axis_map(obj.axis) = false;
assert(all(stride_coords(non_axis_map) == new_extents(non_axis_map)),...
'NWB:Types:Untyped:DataPipe:InvalidSize',...
'Stride size must match non-axis dimensions.');
new_extents(obj.axis) = obj.offset + stride_coords(obj.axis);
end
h5_extents = fliplr(new_extents);
H5D.set_extent(did, h5_extents);

Expand Down

0 comments on commit 24eacab

Please sign in to comment.