Skip to content

Commit 670d29b

Browse files
committed
[Matlab] Final renaming cleanup
- Refactor 'nix.Filter.accept_all' filter. - Refactor 'DataArray.openDimensionIdx' dimension_type. - Final cleanup of nix.File variable names and Primer usage. - CONTRIBUTING.md content rephrasing.
1 parent 20d4a0e commit 670d29b

18 files changed

+85
-85
lines changed

+nix/Block.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178

179179
% maxdepth is an index
180180
function r = findSources(obj, maxDepth)
181-
r = obj.filterFindSources(maxDepth, nix.Filter.accept_all, '');
181+
r = obj.filterFindSources(maxDepth, nix.Filter.acceptall, '');
182182
end
183183

184184
% maxdepth is an index

+nix/DataArray.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
% instead of 0 compared to all other index functions.
8787
fname = strcat(obj.alias, '::openDimensionIdx');
8888
dim = nix_mx(fname, obj.nixhandle, idx);
89-
switch (dim.dimension_type)
89+
switch (dim.dimensionType)
9090
case 'set'
9191
r = nix.Utils.createEntity(dim.handle, @nix.SetDimension);
9292
case 'sampled'

+nix/File.m

+12-12
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
r = nix.Utils.fetchEntityCount(obj, 'blockCount');
5858
end
5959

60-
function r = hasBlock(obj, id_or_name)
61-
r = nix.Utils.fetchHasEntity(obj, 'hasBlock', id_or_name);
60+
function r = hasBlock(obj, idName)
61+
r = nix.Utils.fetchHasEntity(obj, 'hasBlock', idName);
6262
end
6363

64-
function r = openBlock(obj, id_or_name)
65-
r = nix.Utils.openEntity(obj, 'openBlock', id_or_name, @nix.Block);
64+
function r = openBlock(obj, idName)
65+
r = nix.Utils.openEntity(obj, 'openBlock', idName, @nix.Block);
6666
end
6767

6868
function r = openBlockIdx(obj, index)
@@ -92,12 +92,12 @@
9292
r = nix.Utils.fetchEntityCount(obj, 'sectionCount');
9393
end
9494

95-
function r = hasSection(obj, id_or_name)
96-
r = nix.Utils.fetchHasEntity(obj, 'hasSection', id_or_name);
95+
function r = hasSection(obj, idName)
96+
r = nix.Utils.fetchHasEntity(obj, 'hasSection', idName);
9797
end
9898

99-
function r = openSection(obj, id_or_name)
100-
r = nix.Utils.openEntity(obj, 'openSection', id_or_name, @nix.Section);
99+
function r = openSection(obj, idName)
100+
r = nix.Utils.openEntity(obj, 'openSection', idName, @nix.Section);
101101
end
102102

103103
function r = openSectionIdx(obj, index)
@@ -114,13 +114,13 @@
114114
end
115115

116116
% maxdepth is an index
117-
function r = findSections(obj, max_depth)
118-
r = obj.filterFindSections(max_depth, nix.Filter.accept_all, '');
117+
function r = findSections(obj, maxDepth)
118+
r = obj.filterFindSections(maxDepth, nix.Filter.acceptall, '');
119119
end
120120

121121
% maxdepth is an index
122-
function r = filterFindSections(obj, max_depth, filter, val)
123-
r = nix.Utils.find(obj, 'findSections', max_depth, filter, val, @nix.Section);
122+
function r = filterFindSections(obj, maxDepth, filter, val)
123+
r = nix.Utils.find(obj, 'findSections', maxDepth, filter, val, @nix.Section);
124124
end
125125
end
126126

+nix/Filter.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% FILTER available nix custom filters
33

44
enumeration
5-
accept_all (0); % requires an empty value
5+
acceptall (0); % requires an empty value
66
id (1);
77
ids (2); % requires a cell array
88
type (3);

+nix/Section.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797

9898
% maxDepth is handled like an index
9999
function r = findSections(obj, maxDepth)
100-
r = obj.FilterFindSections(maxDepth, nix.Filter.accept_all, '');
100+
r = obj.FilterFindSections(maxDepth, nix.Filter.acceptall, '');
101101
end
102102

103103
% maxDepth is handled like an index

+nix/Source.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
% maxdepth is an index where idx = 0 corresponds to the calling source
7878
function r = findSources(obj, maxDepth)
79-
r = obj.filterFindSources(maxDepth, nix.Filter.accept_all, '');
79+
r = obj.filterFindSources(maxDepth, nix.Filter.acceptall, '');
8080
end
8181

8282
% maxdepth is an index where idx = 0 corresponds to the calling source

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ Style guide
6767
Adhere to the MATLAB Style Guidelines 2.0 as suggested by Richard Johnson.
6868

6969
Furthermore, adhere to these additional guidelines for the nix-mx project:
70-
71-
- keep line length at 90 max.
72-
- use `r` as return variable name of simple (2-3 line) functions.
73-
- always use ';' to terminate proper statements, never for terminating control structures.
70+
- Keep line length at a maximum of 90 characters.
71+
- Use `r` as return variable name of simple (2-3 line) functions.
72+
- Always terminate proper statements with a semicolon.
73+
- Never terminate control structures with a semicolon.
7474
- Structure names should start with a capital letter.
7575
- Structure field names should be camel case and start with a lower case letter.

examples/Primer.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
b = f.blocks{i};
2525

2626
% fetch trial indexes of a certain type = 'nix.trial'
27-
trial_idx = cellfun(@(x) strcmp(x.type, 'nix.trial'), b.tags);
28-
disp([10 b.name ': ' num2str(length(nonzeros(trial_idx))) ' trials']);
27+
trialIdx = cellfun(@(x) strcmp(x.type, 'nix.trial'), b.tags);
28+
disp([10 b.name ': ' num2str(length(nonzeros(trialIdx))) ' trials']);
2929

3030
% display source names
3131
for j = 1:length(b.sources)
@@ -53,7 +53,7 @@
5353

5454
% get actual data
5555
d1 = selection2{1};
56-
dataset = d1.read_all();
56+
dataset = d1.readAllData();
5757

5858
% understand dimensions
5959
dim1 = d1.dimensions{1};
@@ -79,5 +79,5 @@
7979
value = sec.properties{1}.values{1};
8080

8181
% or by name
82-
value = sec.open_property('Name').values{1}.value;
82+
value = sec.openProperty('Name').values{1}.value;
8383

src/nixdataarray.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ namespace nixdataarray {
151151

152152
nix::Dimension d = currObj.getDimension(idx);
153153

154-
struct_builder sb({ 1 }, { "dimension_type", "handle" });
154+
struct_builder sb({ 1 }, { "dimensionType", "handle" });
155155

156156
switch (d.dimensionType()) {
157157
case nix::DimensionType::Set:

tests/RunTests.m

+17-17
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@
2020
%-- id: 7b59c0b9-b200-4b53-951d-6851dbd1cdc8
2121
%-- name: joe097
2222

23-
all_tests = {};
24-
all_tests{end+1} = struct('name', 'FILE', 'tests', {TestFile()});
25-
all_tests{end+1} = struct('name', 'BLOCK', 'tests', {TestBlock()});
26-
all_tests{end+1} = struct('name', 'GROUP', 'tests', {TestGroup()});
27-
all_tests{end+1} = struct('name', 'SOURCE', 'tests', {TestSource()});
28-
all_tests{end+1} = struct('name', 'DATAARRAY', 'tests', {TestDataArray()});
29-
all_tests{end+1} = struct('name', 'TAG', 'tests', {TestTag()});
30-
all_tests{end+1} = struct('name', 'MULTITAG', 'tests', {TestMultiTag()});
31-
all_tests{end+1} = struct('name', 'SECTION', 'tests', {TestSection()});
32-
all_tests{end+1} = struct('name', 'FEATURE', 'tests', {TestFeature()});
33-
all_tests{end+1} = struct('name', 'PROPERTY', 'tests', {TestProperty()});
34-
all_tests{end+1} = struct('name', 'DIMENSIONS', 'tests', {TestDimensions()});
35-
36-
for i = 1:length(all_tests)
37-
fprintf([10 'Execute ' all_tests{i}.name ' tests:\n\n']);
23+
all = {};
24+
all{end+1} = struct('name', 'FILE', 'tests', {TestFile()});
25+
all{end+1} = struct('name', 'BLOCK', 'tests', {TestBlock()});
26+
all{end+1} = struct('name', 'GROUP', 'tests', {TestGroup()});
27+
all{end+1} = struct('name', 'SOURCE', 'tests', {TestSource()});
28+
all{end+1} = struct('name', 'DATAARRAY', 'tests', {TestDataArray()});
29+
all{end+1} = struct('name', 'TAG', 'tests', {TestTag()});
30+
all{end+1} = struct('name', 'MULTITAG', 'tests', {TestMultiTag()});
31+
all{end+1} = struct('name', 'SECTION', 'tests', {TestSection()});
32+
all{end+1} = struct('name', 'FEATURE', 'tests', {TestFeature()});
33+
all{end+1} = struct('name', 'PROPERTY', 'tests', {TestProperty()});
34+
all{end+1} = struct('name', 'DIMENSIONS', 'tests', {TestDimensions()});
35+
36+
for i = 1:length(all)
37+
fprintf([10 'Execute ' all{i}.name ' tests:\n\n']);
3838

39-
for j = 1:length(all_tests{i}.tests)
40-
stats = wrapper(all_tests{i}.tests{j}, stats);
39+
for j = 1:length(all{i}.tests)
40+
stats = wrapper(all{i}.tests{j}, stats);
4141
end
4242
end;
4343

tests/TestBlock.m

+10-10
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,8 @@
776776
% test empty id filter
777777
assert(isempty(f.blocks{1}.filterSources(nix.Filter.id, 'IdoNotExist')));
778778

779-
% test nix.Filter.accept_all
780-
filtered = f.blocks{1}.filterSources(nix.Filter.accept_all, '');
779+
% test nix.Filter.acceptall
780+
filtered = f.blocks{1}.filterSources(nix.Filter.acceptall, '');
781781
assert(size(filtered, 1) == 3);
782782

783783
% test nix.Filter.id
@@ -846,8 +846,8 @@
846846
% test empty id filter
847847
assert(isempty(f.blocks{1}.filterGroups(nix.Filter.id, 'IdoNotExist')));
848848

849-
% test nix.Filter.accept_all
850-
filtered = f.blocks{1}.filterGroups(nix.Filter.accept_all, '');
849+
% test nix.Filter.acceptall
850+
filtered = f.blocks{1}.filterGroups(nix.Filter.acceptall, '');
851851
assert(size(filtered, 1) == 3);
852852

853853
% test nix.Filter.id
@@ -911,8 +911,8 @@
911911
% test empty id filter
912912
assert(isempty(f.blocks{1}.filterTags(nix.Filter.id, 'IdoNotExist')));
913913

914-
% test nix.Filter.accept_all
915-
filtered = f.blocks{1}.filterTags(nix.Filter.accept_all, '');
914+
% test nix.Filter.acceptall
915+
filtered = f.blocks{1}.filterTags(nix.Filter.acceptall, '');
916916
assert(size(filtered, 1) == 3);
917917

918918
% test nix.Filter.id
@@ -977,8 +977,8 @@
977977
% test empty id filter
978978
assert(isempty(f.blocks{1}.filterMultiTags(nix.Filter.id, 'IdoNotExist')));
979979

980-
% test nix.Filter.accept_all
981-
filtered = f.blocks{1}.filterMultiTags(nix.Filter.accept_all, '');
980+
% test nix.Filter.acceptall
981+
filtered = f.blocks{1}.filterMultiTags(nix.Filter.acceptall, '');
982982
assert(size(filtered, 1) == 3);
983983

984984
% test nix.Filter.id
@@ -1048,8 +1048,8 @@
10481048
% test empty id filter
10491049
assert(isempty(f.blocks{1}.filterDataArrays(nix.Filter.id, 'IdoNotExist')));
10501050

1051-
% test nix.Filter.accept_all
1052-
filtered = f.blocks{1}.filterDataArrays(nix.Filter.accept_all, '');
1051+
% test nix.Filter.acceptall
1052+
filtered = f.blocks{1}.filterDataArrays(nix.Filter.acceptall, '');
10531053
assert(size(filtered, 1) == 3);
10541054

10551055
% test nix.Filter.id

tests/TestDataArray.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@
617617
% test empty id filter
618618
assert(isempty(f.blocks{1}.dataArrays{1}.filterSources(nix.Filter.id, 'IdoNotExist')));
619619

620-
% test nix.Filter.accept_all
621-
filtered = f.blocks{1}.dataArrays{1}.filterSources(nix.Filter.accept_all, '');
620+
% test nix.Filter.acceptall
621+
filtered = f.blocks{1}.dataArrays{1}.filterSources(nix.Filter.acceptall, '');
622622
assert(size(filtered, 1) == 3);
623623

624624
% test nix.Filter.id

tests/TestFile.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@
316316
% test empty id filter
317317
assert(isempty(f.filterSections(nix.Filter.id, 'IdoNotExist')));
318318

319-
% test nix.Filter.accept_all
320-
filtered = f.filterSections(nix.Filter.accept_all, '');
319+
% test nix.Filter.acceptall
320+
filtered = f.filterSections(nix.Filter.acceptall, '');
321321
assert(size(filtered, 1) == 3);
322322

323323
% test nix.Filter.id
@@ -373,8 +373,8 @@
373373
% test empty id filter
374374
assert(isempty(f.filterBlocks(nix.Filter.id, 'IdoNotExist')));
375375

376-
% test nix.Filter.accept_all
377-
filtered = f.filterBlocks(nix.Filter.accept_all, '');
376+
% test nix.Filter.acceptall
377+
filtered = f.filterBlocks(nix.Filter.acceptall, '');
378378
assert(size(filtered, 1) == 3);
379379

380380
% test nix.Filter.id

tests/TestGroup.m

+8-8
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,8 @@
913913
% test empty id filter
914914
assert(isempty(f.blocks{1}.groups{1}.filterSources(nix.Filter.id, 'IdoNotExist')));
915915

916-
% test nix.Filter.accept_all
917-
filtered = f.blocks{1}.groups{1}.filterSources(nix.Filter.accept_all, '');
916+
% test nix.Filter.acceptall
917+
filtered = f.blocks{1}.groups{1}.filterSources(nix.Filter.acceptall, '');
918918
assert(size(filtered, 1) == 3);
919919

920920
% test nix.Filter.id
@@ -988,8 +988,8 @@
988988
% test empty id filter
989989
assert(isempty(f.blocks{1}.groups{1}.filterTags(nix.Filter.id, 'IdoNotExist')));
990990

991-
% test nix.Filter.accept_all
992-
filtered = f.blocks{1}.groups{1}.filterTags(nix.Filter.accept_all, '');
991+
% test nix.Filter.acceptall
992+
filtered = f.blocks{1}.groups{1}.filterTags(nix.Filter.acceptall, '');
993993
assert(size(filtered, 1) == 3);
994994

995995
% test nix.Filter.id
@@ -1063,8 +1063,8 @@
10631063
% test empty id filter
10641064
assert(isempty(f.blocks{1}.groups{1}.filterMultiTags(nix.Filter.id, 'IdoNotExist')));
10651065

1066-
% test nix.Filter.accept_all
1067-
filtered = f.blocks{1}.groups{1}.filterMultiTags(nix.Filter.accept_all, '');
1066+
% test nix.Filter.acceptall
1067+
filtered = f.blocks{1}.groups{1}.filterMultiTags(nix.Filter.acceptall, '');
10681068
assert(size(filtered, 1) == 3);
10691069

10701070
% test nix.Filter.id
@@ -1137,8 +1137,8 @@
11371137
% test empty id filter
11381138
assert(isempty(f.blocks{1}.groups{1}.filterDataArrays(nix.Filter.id, 'IdoNotExist')));
11391139

1140-
% test nix.Filter.accept_all
1141-
filtered = f.blocks{1}.groups{1}.filterDataArrays(nix.Filter.accept_all, '');
1140+
% test nix.Filter.acceptall
1141+
filtered = f.blocks{1}.groups{1}.filterDataArrays(nix.Filter.acceptall, '');
11421142
assert(size(filtered, 1) == 3);
11431143

11441144
% test nix.Filter.id

tests/TestMultiTag.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,8 @@
10911091
% test empty id filter
10921092
assert(isempty(f.blocks{1}.multiTags{1}.filterSources(nix.Filter.id, 'IdoNotExist')));
10931093

1094-
% test nix.Filter.accept_all
1095-
filtered = f.blocks{1}.multiTags{1}.filterSources(nix.Filter.accept_all, '');
1094+
% test nix.Filter.acceptall
1095+
filtered = f.blocks{1}.multiTags{1}.filterSources(nix.Filter.acceptall, '');
10961096
assert(size(filtered, 1) == 3);
10971097

10981098
% test nix.Filter.id
@@ -1167,8 +1167,8 @@
11671167
% test empty id filter
11681168
assert(isempty(f.blocks{1}.multiTags{1}.filterReferences(nix.Filter.id, 'IdoNotExist')));
11691169

1170-
% test nix.Filter.accept_all
1171-
filtered = f.blocks{1}.multiTags{1}.filterReferences(nix.Filter.accept_all, '');
1170+
% test nix.Filter.acceptall
1171+
filtered = f.blocks{1}.multiTags{1}.filterReferences(nix.Filter.acceptall, '');
11721172
assert(size(filtered, 1) == 3);
11731173

11741174
% test nix.Filter.id
@@ -1238,8 +1238,8 @@
12381238
% test empty id filter
12391239
assert(isempty(f.blocks{1}.multiTags{1}.filterFeatures(nix.Filter.id, 'IdoNotExist')));
12401240

1241-
% test nix.Filter.accept_all
1242-
filtered = f.blocks{1}.multiTags{1}.filterFeatures(nix.Filter.accept_all, '');
1241+
% test nix.Filter.acceptall
1242+
filtered = f.blocks{1}.multiTags{1}.filterFeatures(nix.Filter.acceptall, '');
12431243
assert(size(filtered, 1) == 2);
12441244

12451245
% test nix.Filter.id

tests/TestSection.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,8 @@
627627
% test empty id filter
628628
assert(isempty(f.sections{1}.filterSections(nix.Filter.id, 'IdoNotExist')));
629629

630-
% test nix.Filter.accept_all
631-
filtered = f.sections{1}.filterSections(nix.Filter.accept_all, '');
630+
% test nix.Filter.acceptall
631+
filtered = f.sections{1}.filterSections(nix.Filter.acceptall, '');
632632
assert(size(filtered, 1) == 3);
633633

634634
% test nix.Filter.id
@@ -679,8 +679,8 @@
679679
% test empty id filter
680680
assert(isempty(f.sections{1}.filterProperties(nix.Filter.id, 'IdoNotExist')));
681681

682-
% test nix.Filter.accept_all
683-
filtered = f.sections{1}.filterProperties(nix.Filter.accept_all, '');
682+
% test nix.Filter.acceptall
683+
filtered = f.sections{1}.filterProperties(nix.Filter.acceptall, '');
684684
assert(size(filtered, 1) == 2);
685685

686686
% test nix.Filter.id

tests/TestSource.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@
315315
% test empty id filter
316316
assert(isempty(f.blocks{1}.sources{1}.filterSources(nix.Filter.id, 'IdoNotExist')));
317317

318-
% test nix.Filter.accept_all
319-
filtered = f.blocks{1}.sources{1}.filterSources(nix.Filter.accept_all, '');
318+
% test nix.Filter.acceptall
319+
filtered = f.blocks{1}.sources{1}.filterSources(nix.Filter.acceptall, '');
320320
assert(size(filtered, 1) == 3);
321321

322322
% test nix.Filter.id

0 commit comments

Comments
 (0)