Skip to content

Commit 75eba69

Browse files
committed
[Matlab] Refactor Section function names
- Refactors all Section function names to CamelCase. - Refactors all affected tests.
1 parent fc2e8ff commit 75eba69

File tree

4 files changed

+312
-314
lines changed

4 files changed

+312
-314
lines changed

+nix/Section.m

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
% Link methods
3636
% ----------------
3737

38-
function [] = set_link(obj, val)
38+
function [] = setLink(obj, val)
3939
if (isempty(val))
4040
fname = strcat(obj.alias, '::setNoneLink');
4141
nix_mx(fname, obj.nix_handle);
@@ -48,68 +48,68 @@
4848
r = nix.Utils.fetchObj(obj, 'openLink', @nix.Section);
4949
end
5050

51-
function r = inherited_properties(obj)
51+
function r = inheritedProperties(obj)
5252
r = nix.Utils.fetchObjList(obj, 'inheritedProperties', @nix.Property);
5353
end
5454

5555
% ----------------
5656
% Section methods
5757
% ----------------
5858

59-
function r = create_section(obj, name, type)
59+
function r = createSection(obj, name, type)
6060
fname = strcat(obj.alias, '::createSection');
6161
h = nix_mx(fname, obj.nix_handle, name, type);
6262
r = nix.Utils.createEntity(h, @nix.Section);
6363
end
6464

65-
function r = delete_section(obj, del)
65+
function r = deleteSection(obj, del)
6666
r = nix.Utils.delete_entity(obj, 'deleteSection', del, 'nix.Section');
6767
end
6868

69-
function r = open_section(obj, id_or_name)
70-
r = nix.Utils.open_entity(obj, 'openSection', id_or_name, @nix.Section);
69+
function r = openSection(obj, idName)
70+
r = nix.Utils.open_entity(obj, 'openSection', idName, @nix.Section);
7171
end
7272

73-
function r = open_section_idx(obj, index)
73+
function r = openSectionIdx(obj, index)
7474
idx = nix.Utils.handle_index(index);
7575
r = nix.Utils.open_entity(obj, 'openSectionIdx', idx, @nix.Section);
7676
end
7777

78-
function r = has_section(obj, id_or_name)
79-
r = nix.Utils.fetchHasEntity(obj, 'hasSection', id_or_name);
78+
function r = hasSection(obj, idName)
79+
r = nix.Utils.fetchHasEntity(obj, 'hasSection', idName);
8080
end
8181

82-
function r = section_count(obj)
82+
function r = sectionCount(obj)
8383
r = nix.Utils.fetchEntityCount(obj, 'sectionCount');
8484
end
8585

86-
function r = filter_sections(obj, filter, val)
86+
function r = filterSections(obj, filter, val)
8787
r = nix.Utils.filter(obj, 'sectionsFiltered', filter, val, @nix.Section);
8888
end
8989

90-
% find_related returns the nearest occurrence downstream of a
90+
% findRelated returns the nearest occurrence downstream of a
9191
% nix.Section matching the filter.
9292
% If no section can be found downstream, it will look for the
9393
% nearest occurrence upstream of a nix.Section matching the filter.
94-
function r = find_related(obj, filter, val)
94+
function r = findRelated(obj, filter, val)
9595
r = nix.Utils.filter(obj, 'findRelated', filter, val, @nix.Section);
9696
end
9797

98-
% maxdepth is handled like an index
99-
function r = find_sections(obj, max_depth)
100-
r = obj.find_filtered_sections(max_depth, nix.Filter.accept_all, '');
98+
% maxDepth is handled like an index
99+
function r = findSections(obj, maxDepth)
100+
r = obj.FilterFindSections(maxDepth, nix.Filter.accept_all, '');
101101
end
102102

103-
% maxdepth is handled like an index
104-
function r = find_filtered_sections(obj, max_depth, filter, val)
105-
r = nix.Utils.find(obj, 'findSections', max_depth, filter, val, @nix.Section);
103+
% maxDepth is handled like an index
104+
function r = FilterFindSections(obj, maxDepth, filter, val)
105+
r = nix.Utils.find(obj, 'findSections', maxDepth, filter, val, @nix.Section);
106106
end
107107

108108
% ----------------
109109
% Property methods
110110
% ----------------
111111

112-
function r = create_property(obj, name, datatype)
112+
function r = createProperty(obj, name, datatype)
113113
if (~isa(datatype, 'nix.DataType'))
114114
err.identifier = 'NIXMX:InvalidArgument';
115115
err.message = 'Please provide a valid nix.DataType';
@@ -121,7 +121,7 @@
121121
end
122122
end
123123

124-
function r = create_property_with_value(obj, name, val)
124+
function r = createPropertyWithValue(obj, name, val)
125125
if (~iscell(val))
126126
val = num2cell(val);
127127
end
@@ -130,7 +130,7 @@
130130
r = nix.Utils.createEntity(h, @nix.Property);
131131
end
132132

133-
function r = delete_property(obj, del)
133+
function r = deleteProperty(obj, del)
134134
if (isstruct(del) && isfield(del, 'id'))
135135
id = del.id;
136136
else
@@ -141,44 +141,44 @@
141141
r = nix_mx(fname, obj.nix_handle, id);
142142
end
143143

144-
function r = open_property(obj, id_or_name)
145-
r = nix.Utils.open_entity(obj, 'openProperty', id_or_name, @nix.Property);
144+
function r = openProperty(obj, idName)
145+
r = nix.Utils.open_entity(obj, 'openProperty', idName, @nix.Property);
146146
end
147147

148-
function r = open_property_idx(obj, index)
148+
function r = openPropertyIdx(obj, index)
149149
idx = nix.Utils.handle_index(index);
150150
r = nix.Utils.open_entity(obj, 'openPropertyIdx', idx, @nix.Property);
151151
end
152152

153-
function r = property_count(obj)
153+
function r = propertyCount(obj)
154154
r = nix.Utils.fetchEntityCount(obj, 'propertyCount');
155155
end
156156

157-
function r = filter_properties(obj, filter, val)
157+
function r = filterProperties(obj, filter, val)
158158
r = nix.Utils.filter(obj, 'propertiesFiltered', filter, val, @nix.Property);
159159
end
160160

161161
% ----------------
162162
% Referring entity methods
163163
% ----------------
164164

165-
function r = referring_data_arrays(obj, varargin)
166-
r = obj.referring_util(@nix.DataArray, 'DataArrays', varargin{:});
165+
function r = referringDataArrays(obj, varargin)
166+
r = obj.referringUtil(@nix.DataArray, 'DataArrays', varargin{:});
167167
end
168168

169-
function r = referring_tags(obj, varargin)
170-
r = obj.referring_util(@nix.Tag, 'Tags', varargin{:});
169+
function r = referringTags(obj, varargin)
170+
r = obj.referringUtil(@nix.Tag, 'Tags', varargin{:});
171171
end
172172

173-
function r = referring_multi_tags(obj, varargin)
174-
r = obj.referring_util(@nix.MultiTag, 'MultiTags', varargin{:});
173+
function r = referringMultiTags(obj, varargin)
174+
r = obj.referringUtil(@nix.MultiTag, 'MultiTags', varargin{:});
175175
end
176176

177-
function r = referring_sources(obj, varargin)
178-
r = obj.referring_util(@nix.Source, 'Sources', varargin{:});
177+
function r = referringSources(obj, varargin)
178+
r = obj.referringUtil(@nix.Source, 'Sources', varargin{:});
179179
end
180180

181-
function r = referring_blocks(obj)
181+
function r = referringBlocks(obj)
182182
r = nix.Utils.fetchObjList(obj, 'referringBlocks', @nix.Block);
183183
end
184184
end
@@ -188,10 +188,10 @@
188188
% ----------------
189189

190190
methods (Access=protected)
191-
% referring_util receives a nix entityConstructor, part of a function
191+
% referringUtil receives a nix entityConstructor, part of a function
192192
% name and varargin to provide abstract access to nix.Section
193193
% referringXXX and referringXXX(Block) methods.
194-
function r = referring_util(obj, entityConstructor, fsuffix, varargin)
194+
function r = referringUtil(obj, entityConstructor, fsuffix, varargin)
195195
if (isempty(varargin))
196196
fname = strcat('referring', fsuffix);
197197
r = nix.Utils.fetchObjList(obj, fname, entityConstructor);

tests/TestFile.m

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
% LICENSE file in the root of the Project.
88

99
function funcs = TestFile
10-
%TESTFILE tests for File
11-
% Detailed explanation goes here
10+
% TESTFILE tests for File
1211

1312
funcs = {};
1413
funcs{end+1} = @testReadOnly;
@@ -419,17 +418,17 @@
419418
f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
420419
sl1 = f.createSection('sectionLvl1', 'nixSection');
421420

422-
sl21 = sl1.create_section('sectionLvl2_1', 'nixSection');
423-
sl22 = sl1.create_section('sectionLvl2_2', 'nixSection');
421+
sl21 = sl1.createSection('sectionLvl2_1', 'nixSection');
422+
sl22 = sl1.createSection('sectionLvl2_2', 'nixSection');
424423

425-
sl31 = sl21.create_section('sectionLvl3_1', 'nixSection');
426-
sl32 = sl21.create_section('sectionLvl3_2', 'nixSection');
427-
sl33 = sl21.create_section('sectionLvl3_3', 'nixSection');
424+
sl31 = sl21.createSection('sectionLvl3_1', 'nixSection');
425+
sl32 = sl21.createSection('sectionLvl3_2', 'nixSection');
426+
sl33 = sl21.createSection('sectionLvl3_3', 'nixSection');
428427

429-
sl41 = sl31.create_section('sectionLvl4_1', 'nixSection');
430-
sl42 = sl31.create_section('sectionLvl4_2', 'nixSection');
431-
sl43 = sl31.create_section('sectionLvl4_3', 'nixSection');
432-
sl44 = sl31.create_section('sectionLvl4_4', 'nixSection');
428+
sl41 = sl31.createSection('sectionLvl4_1', 'nixSection');
429+
sl42 = sl31.createSection('sectionLvl4_2', 'nixSection');
430+
sl43 = sl31.createSection('sectionLvl4_3', 'nixSection');
431+
sl44 = sl31.createSection('sectionLvl4_4', 'nixSection');
433432

434433
% Check invalid entry
435434
err = 'Provide a valid search depth';
@@ -466,17 +465,17 @@
466465
f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
467466
sl1 = f.createSection('sectionLvl1', 'nixSection');
468467

469-
sl21 = sl1.create_section('sectionLvl2_1', 'nixSection');
470-
sl22 = sl1.create_section('sectionLvl2_2', findSection);
468+
sl21 = sl1.createSection('sectionLvl2_1', 'nixSection');
469+
sl22 = sl1.createSection('sectionLvl2_2', findSection);
471470

472-
sl31 = sl21.create_section('sectionLvl3_1', 'nixSection');
473-
sl32 = sl21.create_section('sectionLvl3_2', 'nixSection');
474-
sl33 = sl21.create_section('sectionLvl3_3', findSection);
471+
sl31 = sl21.createSection('sectionLvl3_1', 'nixSection');
472+
sl32 = sl21.createSection('sectionLvl3_2', 'nixSection');
473+
sl33 = sl21.createSection('sectionLvl3_3', findSection);
475474

476-
sl41 = sl31.create_section('sectionLvl4_1', 'nixSection');
477-
sl42 = sl31.create_section('sectionLvl4_2', 'nixSection');
478-
sl43 = sl31.create_section('sectionLvl4_3', findSection);
479-
sl44 = sl31.create_section('sectionLvl4_4', 'nixSection');
475+
sl41 = sl31.createSection('sectionLvl4_1', 'nixSection');
476+
sl42 = sl31.createSection('sectionLvl4_2', 'nixSection');
477+
sl43 = sl31.createSection('sectionLvl4_3', findSection);
478+
sl44 = sl31.createSection('sectionLvl4_4', 'nixSection');
480479

481480
% test find by id
482481
filtered = f.filterFindSections(1, nix.Filter.id, sl41.id);

tests/TestProperty.m

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
% LICENSE file in the root of the Project.
88

99
function funcs = TestProperty
10-
%TESTPROPERTY % Tests for the nix.Property object
11-
% Detailed explanation goes here
10+
% TESTPROPERTY % Tests for the nix.Property object
1211

1312
funcs = {};
1413
funcs{end+1} = @test_attrs;
@@ -23,7 +22,7 @@
2322
function [] = test_attrs( varargin )
2423
f = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
2524
s = f.createSection('testSectionProperty', 'nixSection');
26-
p = s.create_property('testProperty1', nix.DataType.String);
25+
p = s.createProperty('testProperty1', nix.DataType.String);
2726

2827
assert(~isempty(p.id));
2928
assert(strcmpi(p.datatype, 'char'));
@@ -50,7 +49,7 @@
5049
function [] = test_values( varargin )
5150
f = nix.File(fullfile(pwd,'tests','testRW.h5'), nix.FileMode.Overwrite);
5251
s = f.createSection('mainSection', 'nixSection');
53-
currProp = s.create_property_with_value('booleanProperty', {true, false, true});
52+
currProp = s.createPropertyWithValue('booleanProperty', {true, false, true});
5453

5554
assert(size(currProp.values, 1) == 3);
5655
assert(currProp.values{1}.value);
@@ -63,19 +62,19 @@
6362
s = f.createSection('mainSection', 'nixSection');
6463

6564
%-- test update boolean
66-
updateBool = s.create_property_with_value('booleanProperty', {true, false, true});
65+
updateBool = s.createPropertyWithValue('booleanProperty', {true, false, true});
6766
assert(updateBool.values{1}.value);
6867
updateBool.values{1}.value = false;
6968
assert(~updateBool.values{1}.value);
7069

7170
%-- test update string
72-
updateString = s.create_property_with_value('stringProperty', {'this', 'has', 'strings'});
71+
updateString = s.createPropertyWithValue('stringProperty', {'this', 'has', 'strings'});
7372
assert(strcmp(updateString.values{3}.value, 'strings'));
7473
updateString.values{3}.value = 'more strings';
7574
assert(strcmp(updateString.values{3}.value, 'more strings'));
7675

7776
%-- test update double / test set uncertainty
78-
updateDouble = s.create_property_with_value('doubleProperty', {2, 3, 4, 5});
77+
updateDouble = s.createPropertyWithValue('doubleProperty', {2, 3, 4, 5});
7978
assert(updateDouble.values{1}.value == 2);
8079
updateDouble.values{1}.value = 2.2;
8180
assert(updateDouble.values{1}.value == 2.2);
@@ -103,7 +102,7 @@
103102
%-- test add new values by value structure
104103
val1 = newValues.values{1};
105104
val2 = newValues.values{2};
106-
updateNewDouble = s.create_property('doubleProperty2', nix.DataType.Double);
105+
updateNewDouble = s.createProperty('doubleProperty2', nix.DataType.Double);
107106
updateNewDouble.values = {val1, val2};
108107
assert(s.properties{end}.values{2}.value == val2.value);
109108
end
@@ -113,7 +112,7 @@
113112
testFile = fullfile(pwd, 'tests', 'testRW.h5');
114113
f = nix.File(testFile, nix.FileMode.Overwrite);
115114
s = f.createSection('testSection', 'nixSection');
116-
p = s.create_property_with_value('booleanProperty', {true, false, true});
115+
p = s.createPropertyWithValue('booleanProperty', {true, false, true});
117116

118117
assert(p.value_count() == 3);
119118
p.values = {};
@@ -131,7 +130,7 @@
131130
f = nix.File(testFile, nix.FileMode.Overwrite);
132131
s = f.createSection('testSection', 'nixSection');
133132

134-
p = s.create_property_with_value('property1', {true, false, true});
133+
p = s.createPropertyWithValue('property1', {true, false, true});
135134
assert(~isempty(p.values));
136135
p.values_delete();
137136
assert(isempty(p.values));
@@ -148,7 +147,7 @@
148147
s1 = f.createSection('testSection1', 'nixSection');
149148
s2 = f.createSection('testSection2', 'nixSection');
150149

151-
p = s1.create_property_with_value('property', {true, false, true});
150+
p = s1.createPropertyWithValue('property', {true, false, true});
152151

153152
% test invalid property comparison
154153
try
@@ -164,6 +163,6 @@
164163
assert(~p.compare(p));
165164

166165
% test property not eqal
167-
pNEq = s2.create_property_with_value('property', {true, false});
166+
pNEq = s2.createPropertyWithValue('property', {true, false});
168167
assert(p.compare(pNEq) ~= 0);
169168
end

0 commit comments

Comments
 (0)