Skip to content

Commit d5db501

Browse files
committed
[Matlab] Cleanup conditionals and constants
1 parent d1b4cbb commit d5db501

File tree

12 files changed

+35
-35
lines changed

12 files changed

+35
-35
lines changed

+nix/Block.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@
9191
%-- 1D data arrays created with this function.
9292
%-- e.g. size([1 2 3]) returns shape [1 3], which would not
9393
%-- be accepted when trying to add an alias range dimension.
94-
if(shape(1) == 1)
94+
if (shape(1) == 1)
9595
shape(2:size(shape, 2));
9696
end
9797

9898
errorStruct.identifier = 'Block:unsupportedDataType';
99-
if(~isa(datatype, 'nix.DataType'))
99+
if (~isa(datatype, 'nix.DataType'))
100100
errorStruct.message = 'Please provide a valid nix.DataType';
101101
error(errorStruct);
102-
elseif(isequal(datatype, nix.DataType.String))
102+
elseif (isequal(datatype, nix.DataType.String))
103103
errorStruct.message = 'Writing Strings to DataArrays is not supported as of yet.';
104104
error(errorStruct);
105105
else
@@ -115,17 +115,17 @@
115115
%-- 1D data arrays created with this function.
116116
%-- e.g. size([1 2 3]) returns shape [1 3], which would not
117117
%-- be accepted when trying to add an alias range dimension.
118-
if(shape(1) == 1)
118+
if (shape(1) == 1)
119119
shape = size(data, 2);
120120
end
121121

122122
errorStruct.identifier = 'Block:unsupportedDataType';
123-
if(ischar(data))
123+
if (ischar(data))
124124
errorStruct.message = 'Writing Strings to DataArrays is not supported as of yet.';
125125
error(errorStruct);
126-
elseif(islogical(data))
126+
elseif (islogical(data))
127127
dtype = nix.DataType.Bool;
128-
elseif(isnumeric(data))
128+
elseif (isnumeric(data))
129129
dtype = nix.DataType.Double;
130130
else
131131
errorStruct.message = 'DataType of provided data is not supported.';
@@ -267,7 +267,7 @@
267267

268268
%-- Creating a multitag requires an already existing data array
269269
function r = create_multi_tag(obj, name, type, add_data_array)
270-
if(strcmp(class(add_data_array), 'nix.DataArray'))
270+
if (strcmp(class(add_data_array), 'nix.DataArray'))
271271
addID = add_data_array.id;
272272
else
273273
addID = add_data_array;

+nix/DataArray.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
% instead of 0 compared to all other index functions.
8484
fname = strcat(obj.alias, '::openDimensionIdx');
8585
dim = nix_mx(fname, obj.nix_handle, idx);
86-
switch(dim.dimension_type)
86+
switch (dim.dimension_type)
8787
case 'set'
8888
r = nix.SetDimension(dim.handle);
8989
case 'sampled'
@@ -117,21 +117,21 @@
117117
%-- If a DataArray has been created as boolean or numeric,
118118
%-- provide that only values of the proper DataType can be written.
119119
function [] = write_all(obj, data)
120-
if(isinteger(obj.read_all) && isfloat(data))
120+
if (isinteger(obj.read_all) && isfloat(data))
121121
disp('Warning: Writing Float data to an Integer DataArray');
122122
end
123123

124124
errorStruct.identifier = 'DataArray:improperDataType';
125-
if(islogical(obj.read_all) && ~islogical(data))
125+
if (islogical(obj.read_all) && ~islogical(data))
126126
errorStruct.message = strcat('Trying to write', ...
127127
32, class(data), ' to a logical DataArray.');
128128
error(errorStruct);
129-
elseif(isnumeric(obj.read_all) && ~isnumeric(data))
129+
elseif (isnumeric(obj.read_all) && ~isnumeric(data))
130130
errorStruct.message = strcat('Trying to write', ...
131131
32, class(data), ' to a ', 32, class(obj.read_all), ...
132132
' DataArray.');
133133
error(errorStruct);
134-
elseif(ischar(data))
134+
elseif (ischar(data))
135135
%-- Should actually not be reachable at the moment,
136136
%-- since writing Strings to DataArrays is not supported,
137137
%-- but safety first.

+nix/Dynamic.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
methods (Static)
1414
function add_dyn_attr(obj, prop, mode)
15-
if nargin < 3
15+
if (nargin < 3)
1616
mode = 'r';
1717
end
1818

@@ -24,7 +24,7 @@ function add_dyn_attr(obj, prop, mode)
2424
p.SetMethod = @set_method;
2525

2626
function set_method(obj, val)
27-
if strcmp(mode, 'r')
27+
if (strcmp(mode, 'r'))
2828
ME = MException('MATLAB:class:SetProhibited', sprintf(...
2929
'You cannot set the read-only property ''%s'' of %s', ...
3030
prop, class(obj)));
@@ -34,7 +34,7 @@ function set_method(obj, val)
3434
if (isempty(val))
3535
fname = strcat(obj.alias, '::setNone', upper(prop(1)), prop(2:end));
3636
nix_mx(fname, obj.nix_handle, 0);
37-
elseif((strcmp(prop, 'units') || strcmp(prop, 'labels')) && (~iscell(val)))
37+
elseif ((strcmp(prop, 'units') || strcmp(prop, 'labels')) && (~iscell(val)))
3838
%-- BUGFIX: Matlab crashes, if units in Tags and MultiTags
3939
%-- or labels of SetDimension are set using anything else than a cell.
4040
ME = MException('MATLAB:class:SetProhibited', sprintf(...
@@ -78,7 +78,7 @@ function add_dyn_relation(obj, name, constructor)
7878
val = containers.Map();
7979
props = obj.(name);
8080

81-
for i=1:length(props)
81+
for i = 1:length(props)
8282
val(props{i}.name) = cell2mat(props{i}.values);
8383
end
8484
end

+nix/Feature.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
end
4646

4747
function [] = set_data(obj, setData)
48-
if(strcmp(class(setData), 'nix.DataArray'))
48+
if (strcmp(class(setData), 'nix.DataArray'))
4949
setData = setData.id;
5050
end
5151
fname = strcat(obj.alias, '::setData');

+nix/File.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
methods
1818
function obj = File(path, mode)
19-
if ~exist('mode', 'var')
19+
if (~exist('mode', 'var'))
2020
mode = nix.FileMode.ReadWrite; %default to ReadWrite
2121
end
2222
h = nix_mx('File::open', path, mode);

+nix/FileMode.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
% FILEMODE nix file open modes
1111

1212
properties (Constant)
13-
ReadOnly = uint8(0)
14-
ReadWrite = uint8(1)
15-
Overwrite = uint8(2)
13+
ReadOnly = uint8(0);
14+
ReadWrite = uint8(1);
15+
Overwrite = uint8(2);
1616
end
1717

1818
end

+nix/LinkType.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
% LINKTYPE nix link types
1111

1212
properties (Constant)
13-
Tagged = uint8(0)
14-
Untagged = uint8(1)
15-
Indexed = uint8(2)
13+
Tagged = uint8(0);
14+
Untagged = uint8(1);
15+
Indexed = uint8(2);
1616
end
1717

1818
end

+nix/MultiTag.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
% ------------------
9090

9191
function r = add_feature(obj, add_this, link_type)
92-
if(strcmp(class(add_this), 'nix.DataArray'))
92+
if (strcmp(class(add_this), 'nix.DataArray'))
9393
addID = add_this.id;
9494
else
9595
addID = add_this;
@@ -175,7 +175,7 @@
175175
end
176176

177177
function [] = set_extents(obj, add_this)
178-
if(isempty(add_this))
178+
if (isempty(add_this))
179179
fname = strcat(obj.alias, '::setNoneExtents');
180180
nix_mx(fname, obj.nix_handle, 0);
181181
else

+nix/NamedEntity.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
function r = compare(obj, entity)
2525
% Compares first name and second id, return > 0 if the entity
2626
% is larger than the other, 0 if both are equal, and < 0 otherwise.
27-
if(~strcmp(class(obj), class(entity)))
27+
if (~strcmp(class(obj), class(entity)))
2828
error('Only entities of the same class can be compared.');
2929
end
3030
fname = strcat(obj.alias, '::compare');

+nix/RangeDimension.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
end
2828

2929
function r = tick_at(obj, index)
30-
if index > 0
30+
if (index > 0)
3131
index = index - 1;
3232
end
3333
fname = strcat(obj.alias, '::tickAt');
@@ -40,11 +40,11 @@
4040
end
4141

4242
function r = axis(obj, count, startIndex)
43-
if nargin < 3
43+
if (nargin < 3)
4444
startIndex = 0;
4545
end
4646

47-
if(startIndex > 0)
47+
if (startIndex > 0)
4848
startIndex = startIndex - 1;
4949
end
5050

0 commit comments

Comments
 (0)