Mercurial > hg > octave-nkf
changeset 20072:e9f89866074c
maint: Cleanup some .m files to follow Octave coding conventions.
* accumarray.m, validateattributes.m, iscolormap.m, __imread__.m,
__imwrite__.m, imwrite_filename.m, strread.m, getappdata.m,
appearance/annotation.m, shrinkfaces.m, rundemos.m, runtests.m,
datenum.m, datestr.m: Break long lines before && and ||.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 26 Feb 2015 13:13:40 -0500 |
parents | 17d647821d61 |
children | 726df008104d |
files | scripts/general/accumarray.m scripts/general/validateattributes.m scripts/image/iscolormap.m scripts/image/private/__imread__.m scripts/image/private/__imwrite__.m scripts/image/private/imwrite_filename.m scripts/io/strread.m scripts/miscellaneous/getappdata.m scripts/plot/appearance/annotation.m scripts/plot/draw/shrinkfaces.m scripts/testfun/rundemos.m scripts/testfun/runtests.m scripts/time/datenum.m scripts/time/datestr.m |
diffstat | 14 files changed, 41 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/accumarray.m +++ b/scripts/general/accumarray.m @@ -142,8 +142,7 @@ lensubs = cellfun (@length, subs); - if (any (lensubs != lensubs(1)) || - (lenvals > 1 && lenvals != lensubs(1))) + if (any (lensubs != lensubs(1)) || (lenvals > 1 && lenvals != lensubs(1))) error ("accumarray: dimension mismatch"); endif
--- a/scripts/general/validateattributes.m +++ b/scripts/general/validateattributes.m @@ -265,14 +265,14 @@ case "nonnegative", problem = any (A(:) < 0); case "nonzero", problem = any (A(:) == 0); case "positive", problem = any (A(:) <= 0); - case "decreasing", problem = (any (isnan (A(:))) || - any (diff (A(:)) >= 0)); - case "increasing", problem = (any (isnan (A(:))) || - any (diff (A(:)) <= 0)); - case "nondecreasing", problem = (any (isnan (A(:))) || - any (diff (A(:)) < 0)); - case "nonincreasing", problem = (any (isnan (A(:))) || - any (diff (A(:)) > 0)); + case "decreasing", problem = (any (isnan (A(:))) + || any (diff (A(:)) >= 0)); + case "increasing", problem = (any (isnan (A(:))) + || any (diff (A(:)) <= 0)); + case "nondecreasing", problem = (any (isnan (A(:))) + || any (diff (A(:)) < 0)); + case "nonincreasing", problem = (any (isnan (A(:))) + || any (diff (A(:)) > 0)); case "size", A_size = size (A); w_size = attr{idx++};
--- a/scripts/image/iscolormap.m +++ b/scripts/image/iscolormap.m @@ -35,9 +35,9 @@ print_usage; endif - retval = (isnumeric (cmap) && isreal (cmap) && - ndims (cmap) == 2 && columns (cmap) == 3 && isa (cmap, "double") && - min (cmap(:)) >= 0 && max (cmap(:)) <= 1); + retval = (isnumeric (cmap) && isreal (cmap) && ndims (cmap) == 2 + && columns (cmap) == 3 && isa (cmap, "double") + && min (cmap(:)) >= 0 && max (cmap(:)) <= 1); endfunction
--- a/scripts/image/private/__imread__.m +++ b/scripts/image/private/__imread__.m @@ -73,8 +73,8 @@ indexes = find (indexes); if (indexes) options.index = varargin{indexes+1}; - if (! is_valid_index_option (options.index) && - ! (ischar (options.index) && strcmpi (options.index, "all"))) + if (! is_valid_index_option (options.index) + && ! (ischar (options.index) && strcmpi (options.index, "all"))) error ("imread: value for %s must be a vector or the string `all'"); endif endif
--- a/scripts/image/private/__imwrite__.m +++ b/scripts/image/private/__imwrite__.m @@ -60,9 +60,9 @@ elseif (size (options.alpha, 3) != 1) error ("imwrite: 3rd dimension of matrix for %s must be singleton", param_list{idx}); - elseif (ndims (options.alpha) > 4 || - any (size (options.alpha)([1 2]) != size (img)([1 2])) || - size (options.alpha, 4) != size (img, 4)) + elseif (ndims (options.alpha) > 4 + || any (size (options.alpha)([1 2]) != size (img)([1 2])) + || size (options.alpha, 4) != size (img, 4)) error ("imwrite: matrix for %s must have same dimension as image", param_list{idx}); endif @@ -88,8 +88,8 @@ case "disposalmethod" options.disposalmethod = param_list{idx+1}; - if (! ischar (options.disposalmethod) && - ! iscellstr (options.disposalmethod)) + if (! ischar (options.disposalmethod) + && ! iscellstr (options.disposalmethod)) error ("imwrite: value for %s must be a string or cell array of strings", param_list{idx}); elseif (! iscell (options.disposalmethod)) @@ -115,8 +115,8 @@ case "loopcount" options.loopcount = param_list{idx+1}; if (! isscalar (options.loopcount) || ! isnumeric (options.loopcount) - || (! isinf (options.loopcount) && (options.loopcount < 0 || - options.loopcount > 65535))) + || (! isinf (options.loopcount) + && (options.loopcount < 0 || options.loopcount > 65535))) error ("imwrite: value for %s must be Inf or between 0 and 65535", param_list{idx}); endif
--- a/scripts/image/private/imwrite_filename.m +++ b/scripts/image/private/imwrite_filename.m @@ -48,9 +48,9 @@ ## is a string, we consider it the file extension. Otherwise we will ## extract what we can from the previously found filename. options_idx = filename_idx + 1; - if (numel (varargin) > filename_idx && - rem (length (varargin) - filename_idx, 2) != 0 && - ischar (varargin{filename_idx + 1})) + if (numel (varargin) > filename_idx + && rem (length (varargin) - filename_idx, 2) != 0 + && ischar (varargin{filename_idx + 1})) ext = varargin{filename_idx + 1}; options_idx++; else
--- a/scripts/io/strread.m +++ b/scripts/io/strread.m @@ -245,8 +245,8 @@ case "matlab" [comment_start, comment_end] = deal ("%" , "eol_char"); otherwise - if (ischar (varargin{n+1}) || - (numel (varargin{n+1}) == 1 && iscellstr (varargin{n+1}))) + if (ischar (varargin{n+1}) + || (numel (varargin{n+1}) == 1 && iscellstr (varargin{n+1}))) [comment_start, comment_end] = deal (char (varargin{n+1}), "eol_char"); elseif (iscellstr (varargin{n+1}) && numel (varargin{n+1}) == 2) [comment_start, comment_end] = deal (varargin{n+1}{:});
--- a/scripts/miscellaneous/getappdata.m +++ b/scripts/miscellaneous/getappdata.m @@ -52,8 +52,7 @@ for i = 1:numel (h) value{i} = []; pval = get (h(i)); - if (isfield (pval, "__appdata__") && - isfield (pval.__appdata__, name)) + if (isfield (pval, "__appdata__") && isfield (pval.__appdata__, name)) value{i} = pval.__appdata__.(name); endif endfor
--- a/scripts/plot/appearance/annotation.m +++ b/scripts/plot/appearance/annotation.m @@ -190,8 +190,8 @@ y = varargin{2}; varargin(1:2) = []; - if (isnumeric (x) && isnumeric (y) && - length (x) == 2 && length (y) == 2) + if (isnumeric (x) && isnumeric (y) + && length (x) == 2 && length (y) == 2) lims = [x(1) y(1) diff(x) diff(y)]; else error ("annotation: expect 2 elements vectors for X and Y");
--- a/scripts/plot/draw/shrinkfaces.m +++ b/scripts/plot/draw/shrinkfaces.m @@ -76,8 +76,8 @@ colors = []; p = varargin{1}; - if (isscalar (p) && ishandle (p) && nargin < 3 && - strcmp (get (p, "type"), "patch")) + if (isscalar (p) && ishandle (p) && nargin < 3 + && strcmp (get (p, "type"), "patch")) faces = get (p, "Faces"); vertices = get (p, "Vertices"); colors = get (p, "FaceVertexCData");
--- a/scripts/testfun/rundemos.m +++ b/scripts/testfun/rundemos.m @@ -66,8 +66,8 @@ dirs = {}; for i = 1:numel (flist) f = flist{i}; - if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) || - (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) + if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) + || (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) f = fullfile (directory, f); if (has_demos (f)) try
--- a/scripts/testfun/runtests.m +++ b/scripts/testfun/runtests.m @@ -69,8 +69,8 @@ fflush (stdout); for i = 1:numel (flist) f = flist{i}; - if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) || - (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) + if ((length (f) > 2 && strcmpi (f((end-1):end), ".m")) + || (length (f) > 3 && strcmpi (f((end-2):end), ".cc"))) ff = fullfile (directory, f); if (has_tests (ff)) print_test_file_name (f);
--- a/scripts/time/datenum.m +++ b/scripts/time/datenum.m @@ -96,8 +96,8 @@ persistent monthstart = [306; 337; 0; 31; 61; 92; 122; 153; 184; 214; 245; 275]; persistent monthlength = [31; 28; 31; 30; 31; 30; 31; 31; 30; 31; 30; 31]; - if (nargin == 0 || nargin > 6 || - (nargin > 2 && (ischar (year) || iscellstr (year)))) + if (nargin == 0 || nargin > 6 + || (nargin > 2 && (ischar (year) || iscellstr (year)))) print_usage (); endif @@ -130,8 +130,8 @@ if (floor (month) != month) fracmonth = month - floor (month); month = floor (month); - if ((mod (month-1,12) + 1) == 2 && - (floor (year/4) - floor (year/100) + floor (year/400)) != 0) + if ((mod (month-1,12) + 1) == 2 + && (floor (year/4) - floor (year/100) + floor (year/400)) != 0) ## leap year day += fracmonth * 29; else
--- a/scripts/time/datestr.m +++ b/scripts/time/datestr.m @@ -183,8 +183,8 @@ if (columns (date) == 6) ## Make sure that the input really is a datevec. maxdatevec = [Inf, 12, 31, 23, 59, 60]; - if (any (max (date, 1) > maxdatevec) || - any (date(:,1:5) != floor (date(:,1:5)))) + if (any (max (date, 1) > maxdatevec) + || any (date(:,1:5) != floor (date(:,1:5)))) v = datevec (date, p); endif endif