Skip to content

Commit 98edc2c

Browse files
committed
[Matlab] Refactor DataArray function names
- Refactors all DataArray function names to CamelCase. - Refactors all affected tests. - renamed write_all and read_all to writeAllData and readAllData.
1 parent 4a6981e commit 98edc2c

File tree

7 files changed

+183
-182
lines changed

7 files changed

+183
-182
lines changed

+nix/Block.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
end
127127

128128
r = obj.createDataArray(name, nixtype, dtype, shape);
129-
r.write_all(data);
129+
r.writeAllData(data);
130130
end
131131

132132
function r = hasDataArray(obj, idName)

+nix/DataArray.m

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,31 @@
5757
end
5858
end
5959

60-
function r = append_set_dimension(obj)
60+
function r = appendSetDimension(obj)
6161
fname = strcat(obj.alias, '::appendSetDimension');
6262
h = nix_mx(fname, obj.nix_handle);
6363
r = nix.Utils.createEntity(h, @nix.SetDimension);
6464
end
6565

66-
function r = append_sampled_dimension(obj, interval)
66+
function r = appendSampledDimension(obj, interval)
6767
fname = strcat(obj.alias, '::appendSampledDimension');
6868
h = nix_mx(fname, obj.nix_handle, interval);
6969
r = nix.Utils.createEntity(h, @nix.SampledDimension);
7070
end
7171

72-
function r = append_range_dimension(obj, ticks)
72+
function r = appendRangeDimension(obj, ticks)
7373
fname = strcat(obj.alias, '::appendRangeDimension');
7474
h = nix_mx(fname, obj.nix_handle, ticks);
7575
r = nix.Utils.createEntity(h, @nix.RangeDimension);
7676
end
7777

78-
function r = append_alias_range_dimension(obj)
78+
function r = appendAliasRangeDimension(obj)
7979
fname = strcat(obj.alias, '::appendAliasRangeDimension');
8080
h = nix_mx(fname, obj.nix_handle);
8181
r = nix.Utils.createEntity(h, @nix.RangeDimension);
8282
end
8383

84-
function r = open_dimension_idx(obj, idx)
84+
function r = openDimensionIdx(obj, idx)
8585
% Getting the dimension by index starts with 1
8686
% instead of 0 compared to all other index functions.
8787
fname = strcat(obj.alias, '::openDimensionIdx');
@@ -96,20 +96,20 @@
9696
end
9797
end
9898

99-
function r = delete_dimensions(obj)
99+
function r = deleteDimensions(obj)
100100
fname = strcat(obj.alias, '::deleteDimensions');
101101
r = nix_mx(fname, obj.nix_handle);
102102
end
103103

104-
function r = dimension_count(obj)
104+
function r = dimensionCount(obj)
105105
r = nix.Utils.fetchEntityCount(obj, 'dimensionCount');
106106
end
107107

108108
% -----------------
109109
% Data access methods
110110
% -----------------
111111

112-
function r = read_all(obj)
112+
function r = readAllData(obj)
113113
fname = strcat(obj.alias, '::readAll');
114114
data = nix_mx(fname, obj.nix_handle);
115115
r = nix.Utils.transpose_array(data);
@@ -118,18 +118,19 @@
118118
%-- TODO add (optional) offset
119119
%-- If a DataArray has been created as boolean or numeric,
120120
%-- provide that only values of the proper DataType can be written.
121-
function [] = write_all(obj, data)
122-
if (isinteger(obj.read_all) && isfloat(data))
121+
function [] = writeAllData(obj, data)
122+
if (isinteger(obj.readAllData) && isfloat(data))
123123
disp('Warning: Writing Float data to an Integer DataArray');
124124
end
125125

126126
err.identifier = 'NIXMX:improperDataType';
127-
if (islogical(obj.read_all) && ~islogical(data))
127+
if (islogical(obj.readAllData) && ~islogical(data))
128128
m = sprintf('Trying to write %s to a logical DataArray', class(data));
129129
err.message = m;
130130
error(err);
131-
elseif (isnumeric(obj.read_all) && ~isnumeric(data))
132-
m = sprintf('Trying to write %s to a %s DataArray', class(data), class(obj.read_all));
131+
elseif (isnumeric(obj.readAllData) && ~isnumeric(data))
132+
m = sprintf('Trying to write %s to a %s DataArray', ...
133+
class(data), class(obj.readAllData));
133134
err.message = m;
134135
error(err);
135136
elseif (ischar(data))
@@ -159,7 +160,7 @@
159160
% or remodels the size of an array to a completely different
160161
% shape, existing data that does not fit into the new shape
161162
% will be lost!
162-
function [] = set_data_extent(obj, extent)
163+
function [] = setDataExtent(obj, extent)
163164
fname = strcat(obj.alias, '::setDataExtent');
164165
nix_mx(fname, obj.nix_handle, extent);
165166
end

tests/TestBlock.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
da = b.createDataArray(doubleName, dtype, nix.DataType.Double, [2 3]);
9393
assert(strcmp(da.name, doubleName));
9494
assert(strcmp(da.type, dtype));
95-
tmp = da.read_all();
95+
tmp = da.readAllData();
9696
assert(all(tmp(:) == 0));
9797

9898
try
@@ -138,17 +138,17 @@
138138
assert(strcmp(da.name, numName));
139139
assert(strcmp(da.type, daType));
140140

141-
tmp = da.read_all();
141+
tmp = da.readAllData();
142142
assert(strcmp(class(tmp), class(numData)));
143143
assert(isequal(size(tmp), size(numData)));
144144
assert(isequal(tmp, numData));
145145

146146
logName = 'logicalDataArray';
147147
logData = logical([1 0 1; 0 1 0; 1 0 1]);
148148
da = b.createDataArrayFromData(logName, daType, logData);
149-
assert(islogical(da.read_all));
150-
assert(isequal(size(da.read_all), size(logData)));
151-
assert(isequal(da.read_all, logData));
149+
assert(islogical(da.readAllData));
150+
assert(isequal(size(da.readAllData), size(logData)));
151+
assert(isequal(da.readAllData, logData));
152152

153153
try
154154
b.createDataArrayFromData('stringDataArray', daType, ['a' 'b']);

0 commit comments

Comments
 (0)