Skip to content

Commit 35bebec

Browse files
committed
aliasRangeDim: dim shape quick fix
1 parent 0ed68a2 commit 35bebec

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

+nix/Block.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@
6464

6565
function da = create_data_array_from_data(obj, name, nixtype, data)
6666
shape = size(data);
67+
%-- Quick fix to enable alias range dimension with
68+
%-- 1D data arrays created with this function.
69+
%-- e.g. size([1 2 3]) returns shape [1 3], which would not
70+
%-- be accepted when trying to add an alias range dimension.
71+
%-- TODO Remove this when a cleverer solution presents itself.
72+
if(size(data, 1) == 1)
73+
shape = size(data, 2);
74+
end;
6775
dtype = class(data);
6876

6977
da = obj.create_data_array(name, nixtype, dtype, shape);

tests/TestDataArray.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,20 @@
202202
assert(f.blocks{1}.dataArrays{2}.dimensions{1}.isAlias);
203203

204204
clear daAlias da b f;
205-
f = nix.File(fileName, nix.FileMode.ReadOnly);
205+
f = nix.File(fileName, nix.FileMode.ReadWrite);
206206
assert(f.blocks{1}.dataArrays{2}.dimensions{1}.isAlias);
207+
208+
%-- Test for the alias dimension shape work around
209+
daAliasWa = f.blocks{1}.create_data_array_from_data('aliasDimWTest1', ...
210+
'nix.DataArray', [1 2 3]);
211+
daAliasWa.append_alias_range_dimension();
212+
assert(daAliasWa.dimensions{1}.isAlias);
213+
214+
daAliasWa = f.blocks{1}.create_data_array_from_data('aliasDimWATest2', ...
215+
'nix.DataArray', [1; 2; 3]);
216+
assert(isequal(daAliasWa.shape, [3 1]));
217+
218+
daAliasWa = f.blocks{1}.create_data_array_from_data('aliasDimWATest3', ...
219+
'nix.DataArray', [1 2 3; 2 4 5; 3 6 7]);
220+
assert(isequal(daAliasWa.shape, [3 3]));
207221
end

0 commit comments

Comments
 (0)