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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 12 additions & 12 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 17 additions & 17 deletions
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

0 commit comments

Comments
 (0)