Skip to content

Commit 504cd4b

Browse files
committed
[Matlab] Refactor File index use
1 parent d8692bd commit 504cd4b

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

+nix/DataArray.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
dimensions{i} = nix.Utils.createEntity(currList(i).dimension, ...
5353
@nix.RangeDimension);
5454
otherwise
55-
disp('some dimension type is unknown! skip')
55+
disp('some dimension type is unknown! skip');
5656
end
5757
end
5858
end

+nix/File.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
r = nix.Utils.open_entity(obj, 'openBlock', id_or_name, @nix.Block);
6666
end
6767

68-
function r = open_block_idx(obj, idx)
68+
function r = open_block_idx(obj, index)
69+
idx = nix.Utils.handle_index(index);
6970
r = nix.Utils.open_entity(obj, 'openBlockIdx', idx, @nix.Block);
7071
end
7172

@@ -99,7 +100,8 @@
99100
r = nix.Utils.open_entity(obj, 'openSection', id_or_name, @nix.Section);
100101
end
101102

102-
function r = open_section_idx(obj, idx)
103+
function r = open_section_idx(obj, index)
104+
idx = nix.Utils.handle_index(index);
103105
r = nix.Utils.open_entity(obj, 'openSectionIdx', idx, @nix.Section);
104106
end
105107

tests/TestFile.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@
236236
s2 = f.create_section('testSection2', 'nixSection');
237237
s3 = f.create_section('testSection3', 'nixSection');
238238

239-
assert(strcmp(f.open_section_idx(0).name, s1.name));
240-
assert(strcmp(f.open_section_idx(1).name, s2.name));
241-
assert(strcmp(f.open_section_idx(2).name, s3.name));
239+
assert(strcmp(f.open_section_idx(1).name, s1.name));
240+
assert(strcmp(f.open_section_idx(2).name, s2.name));
241+
assert(strcmp(f.open_section_idx(3).name, s3.name));
242242
end
243243

244244
function [] = test_open_block( varargin )
@@ -263,9 +263,9 @@
263263
b2 = f.create_block('testBlock2', 'nixBlock');
264264
b3 = f.create_block('testBlock3', 'nixBlock');
265265

266-
assert(strcmp(f.open_block_idx(0).name, b1.name));
267-
assert(strcmp(f.open_block_idx(1).name, b2.name));
268-
assert(strcmp(f.open_block_idx(2).name, b3.name));
266+
assert(strcmp(f.open_block_idx(1).name, b1.name));
267+
assert(strcmp(f.open_block_idx(2).name, b2.name));
268+
assert(strcmp(f.open_block_idx(3).name, b3.name));
269269
end
270270

271271
%% Test: nix.File has nix.Block by ID or name

0 commit comments

Comments
 (0)