From ce543cd6568b36ccbea6527e4394973690083ada Mon Sep 17 00:00:00 2001 From: Rik Date: Fri, 24 Nov 2023 22:47:19 -0800 Subject: [PATCH] maint: Style check m-files in scripts/ directory before 9.1 release. * scripts/ode/private/ode_event_handler.m, scripts/ode/private/odemergeopts.m, scripts/ode/private/runge_kutta_interpolate.m, scripts/optimization/sqp.m, scripts/pkg/private/build.m, scripts/plot/appearance/text.m, scripts/plot/draw/quiver3.m, scripts/set/ismembertol.m, scripts/signal/unwrap.m, scripts/specfun/betainc.m, scripts/specfun/primes.m, scripts/statistics/cov.m, scripts/statistics/mad.m, scripts/statistics/mode.m, scripts/strings/dec2bin.m, scripts/strings/unicode2native.m, scripts/time/datevec.m: Style check m-files in scripts/ directory before 9.1 release. --- scripts/general/interp2.m | 2 +- scripts/miscellaneous/license.m | 2 +- scripts/ode/private/integrate_adaptive.m | 2 +- scripts/ode/private/ode_event_handler.m | 4 ++-- scripts/ode/private/odemergeopts.m | 3 +-- scripts/ode/private/runge_kutta_interpolate.m | 2 +- scripts/optimization/sqp.m | 2 +- scripts/pkg/private/build.m | 4 ++-- scripts/plot/appearance/text.m | 4 ++-- scripts/plot/draw/quiver3.m | 1 + scripts/set/ismembertol.m | 6 +++--- scripts/signal/unwrap.m | 3 +++ scripts/specfun/betainc.m | 4 ++-- scripts/specfun/primes.m | 8 ++++---- scripts/statistics/cov.m | 1 + scripts/statistics/mad.m | 5 +++-- scripts/statistics/mode.m | 2 +- scripts/strings/dec2bin.m | 2 +- scripts/strings/unicode2native.m | 4 ++-- scripts/time/datevec.m | 2 +- 20 files changed, 34 insertions(+), 29 deletions(-) diff --git a/scripts/general/interp2.m b/scripts/general/interp2.m index 1f08ed2a59..2675c65fb1 100644 --- a/scripts/general/interp2.m +++ b/scripts/general/interp2.m @@ -446,7 +446,7 @@ h_x = (XI - reshape (X(idx_x), size (idx_x))) / spread_x; h_y = (YI - reshape (Y(idx_y), size (idx_y))) / spread_y; - # adjust indexes for padding + ## adjust indexes for padding idx_x += -kernel_bounds(1) - 1; idx_y += -kernel_bounds(1) - 1; diff --git a/scripts/miscellaneous/license.m b/scripts/miscellaneous/license.m index d0d09ca683..f01748940e 100644 --- a/scripts/miscellaneous/license.m +++ b/scripts/miscellaneous/license.m @@ -157,7 +157,7 @@ %! list = pkg ("list"); %! for idx = 1: numel (list) %! name = list{idx}.name; -%! if (list{idx}.loaded); +%! if (list{idx}.loaded) %! assert ((license ("inuse", name)).feature, name); %! else %! rv = license ("inuse", name); diff --git a/scripts/ode/private/integrate_adaptive.m b/scripts/ode/private/integrate_adaptive.m index dadd22d8b6..5427f17a95 100644 --- a/scripts/ode/private/integrate_adaptive.m +++ b/scripts/ode/private/integrate_adaptive.m @@ -97,7 +97,7 @@ ## Initialize Refine value refine = options.Refine; - if isempty (refine) + if (isempty (refine)) refine = 1; elseif ((refine != round (refine)) || (refine < 1)) refine = 1; diff --git a/scripts/ode/private/ode_event_handler.m b/scripts/ode/private/ode_event_handler.m index d2f1d73cd7..1cabaaa27e 100644 --- a/scripts/ode/private/ode_event_handler.m +++ b/scripts/ode/private/ode_event_handler.m @@ -133,7 +133,7 @@ evtcntnew += 1; endfor ## Sort by time of event - if length (idx) > 1 + if (length (idx) > 1) [tnews, idx_sort] = sort (tnews, "ascend"); idxs = idx(idx_sort); ynews = ynews(idx_sort,:); @@ -144,7 +144,7 @@ ## Check for terminal events and remove any events after terminal. ## Any events at same time as first terminal event will be retained. idx3 = find (terms, 1); # Find first terminal event by time - if ! isempty (idx3) + if (! isempty (idx3)) t_cutoff = tnews(idx3); ## Last index to return evtcntnew = find (tnews == t_cutoff, 1, "last"); diff --git a/scripts/ode/private/odemergeopts.m b/scripts/ode/private/odemergeopts.m index 7bfed27d2a..abc6aa4864 100644 --- a/scripts/ode/private/odemergeopts.m +++ b/scripts/ode/private/odemergeopts.m @@ -32,8 +32,7 @@ ## but we don't use that here. Should the calls be fixed or should we ## do something with the solver argument here? -function options = odemergeopts (caller, useroptions, options, classes, - attributes, solver); +function options = odemergeopts (caller, useroptions, options, classes, attributes, solver) for [value, key] = options diff --git a/scripts/ode/private/runge_kutta_interpolate.m b/scripts/ode/private/runge_kutta_interpolate.m index b30ba34ce7..c9b4c6fac1 100644 --- a/scripts/ode/private/runge_kutta_interpolate.m +++ b/scripts/ode/private/runge_kutta_interpolate.m @@ -24,7 +24,7 @@ ######################################################################## ## -*- texinfo -*- -## @deftypefn {} {@var{u_interp} =} odemergeopts (@var{order}, @var{z}, @var{t}, @var{k_vals}) +## @deftypefn {} {@var{u_interp} =} odemergeopts (@var{order}, @var{z}, @var{t}, @var{u}, @var{k_vals}) ## Undocumented internal function. ## @end deftypefn diff --git a/scripts/optimization/sqp.m b/scripts/optimization/sqp.m index 75889f2e6f..65e2846f94 100644 --- a/scripts/optimization/sqp.m +++ b/scripts/optimization/sqp.m @@ -732,7 +732,7 @@ ub = globals.ub - x(ubidx, 1); else ub = []; - end + endif res = [ci; lb; ub]; diff --git a/scripts/pkg/private/build.m b/scripts/pkg/private/build.m index 541804b203..e06bba054a 100644 --- a/scripts/pkg/private/build.m +++ b/scripts/pkg/private/build.m @@ -77,10 +77,10 @@ function build (builddir, tarballs, verbose) else arch_abi = getarch (); configure_make (desc, build_root, verbose); - if exist (fullfile (build_root, "src", "configure"), "file") + if (exist (fullfile (build_root, "src", "configure"), "file")) unlink (fullfile (build_root, "src", "configure")); endif - if exist (fullfile (build_root, "src", "Makefile"), "file") + if (exist (fullfile (build_root, "src", "Makefile"), "file")) unlink (fullfile (build_root, "src", "Makefile")); endif endif diff --git a/scripts/plot/appearance/text.m b/scripts/plot/appearance/text.m index 35acb33baa..afeee889b9 100644 --- a/scripts/plot/appearance/text.m +++ b/scripts/plot/appearance/text.m @@ -245,7 +245,7 @@ %! va = {"bottom", "middle", "top"}; %! x = [0.25 0.5 0.75]; %! y = x; -%! for t = 0:30:359; +%! for t = 0:30:359 %! for nh = 1:numel (ha) %! for nv = 1:numel (va) %! text (x(nh), y(nv), "Hello World", ... @@ -271,7 +271,7 @@ %! "facealpha", 0); %! colors = jet (9); %! ii = 1; -%! for t = 0:45:359; +%! for t = 0:45:359 %! ii = ii +1; %! text (25, 25, 0, "Vertical Alignment = Bottom", ... %! "rotation", t, ... diff --git a/scripts/plot/draw/quiver3.m b/scripts/plot/draw/quiver3.m index 4033244788..f4ff73668a 100644 --- a/scripts/plot/draw/quiver3.m +++ b/scripts/plot/draw/quiver3.m @@ -108,6 +108,7 @@ endfunction + %!demo %! clf; %! colormap ("default"); diff --git a/scripts/set/ismembertol.m b/scripts/set/ismembertol.m index 6a269d67d7..b0f149a7e5 100644 --- a/scripts/set/ismembertol.m +++ b/scripts/set/ismembertol.m @@ -93,8 +93,7 @@ endif if (nargin < 3 || ! isnumeric (varargin{1})) - # defaut tolerance - tol = 1e-6; + tol = 1e-6; # default tolerance else tol = varargin{1}; varargin(1) = []; @@ -163,7 +162,7 @@ endif s_idx = reshape (s_idx, sa); tf = reshape (tf, sa); - else # all_indices + else # all_indices s_idx = cell (size(a)); tf = zeros (size(a)); C = unique (s_j); @@ -225,6 +224,7 @@ endfunction + %!demo %! ## Group random data %! A = rand (1000, 2); diff --git a/scripts/signal/unwrap.m b/scripts/signal/unwrap.m index e45975957e..b99f6dc398 100644 --- a/scripts/signal/unwrap.m +++ b/scripts/signal/unwrap.m @@ -158,6 +158,7 @@ endif endif + endfunction @@ -192,8 +193,10 @@ front_gap_sizes = (sum (nf_front, 1))(any (nf_front, 1))(:); x(nf_front) = repelems (x(locs_after), ... [1:numel(front_gap_sizes); front_gap_sizes'])'; + endfunction + %!shared i, t, r, w, tol %! i = 0; %! t = []; diff --git a/scripts/specfun/betainc.m b/scripts/specfun/betainc.m index 4b5a709b87..39fa62f47d 100644 --- a/scripts/specfun/betainc.m +++ b/scripts/specfun/betainc.m @@ -87,7 +87,7 @@ error ("betainc: all inputs must be real"); endif - if ! (isnumeric (x) && isnumeric (a) && isnumeric (b)) + if (! (isnumeric (x) && isnumeric (a) && isnumeric (b))) error ("betainc: all inputs must be numeric"); endif @@ -124,7 +124,7 @@ ## For x = 0 or 1, the output always reduces to 0 or 1. Input validation ## ensures all interger inputs must be 0 or 1. I = x; - return + return; else I = zeros (size (x), class (x)); endif diff --git a/scripts/specfun/primes.m b/scripts/specfun/primes.m index 4b46765d9d..7808af127e 100644 --- a/scripts/specfun/primes.m +++ b/scripts/specfun/primes.m @@ -58,9 +58,9 @@ cls = class (n); # if n is not double, store its class n = double (n); # and use only double for internal use. - # This conversion is needed for both calculation speed (twice as fast as - # integer) and also for the accuracy of the sieve calculation when given - # integer input, to avoid unwanted rounding in the sieve lengths. + ## This conversion is needed for both calculation speed (twice as fast as + ## integer) and also for the accuracy of the sieve calculation when given + ## integer input, to avoid unwanted rounding in the sieve lengths. if (n > flintmax ()) warning ("primes: input exceeds flintmax. Results may be inaccurate."); @@ -107,7 +107,7 @@ p = sort ([2, 3, 6*find(sievem)-1, 6*find(sievep)+1]); endif - # cast back to the type of the input + ## cast back to the type of the input p = cast (p, cls); endfunction diff --git a/scripts/statistics/cov.m b/scripts/statistics/cov.m index f7c6f3d11f..c765015f1c 100644 --- a/scripts/statistics/cov.m +++ b/scripts/statistics/cov.m @@ -302,6 +302,7 @@ endswitch endfunction + %!test %! x = rand (10); %! cx1 = cov (x); diff --git a/scripts/statistics/mad.m b/scripts/statistics/mad.m index 67dfd37577..0063a109d6 100644 --- a/scripts/statistics/mad.m +++ b/scripts/statistics/mad.m @@ -97,12 +97,12 @@ ## First check for special empty case. if (isempty (x) && ndims (x) == 2 && size (x) == [0, 0]) - if (isa (x, "single")) + if (isa (x, "single")) m = NaN ("single"); else m = NaN; endif - return + return; endif ## Then find the first non-singleton dimension. @@ -119,6 +119,7 @@ endfunction + %!assert (mad (123), 0) %!assert (mad (Inf), NaN) %!assert (mad ([3, Inf]),Inf) diff --git a/scripts/statistics/mode.m b/scripts/statistics/mode.m index a1f875996f..10cb222390 100644 --- a/scripts/statistics/mode.m +++ b/scripts/statistics/mode.m @@ -88,7 +88,7 @@ c(:) = NaN (1, 0); endif endif - return + return; endif if (dim > nd || sz(dim) == 1) diff --git a/scripts/strings/dec2bin.m b/scripts/strings/dec2bin.m index 8d12f41930..9057f82c1e 100644 --- a/scripts/strings/dec2bin.m +++ b/scripts/strings/dec2bin.m @@ -79,7 +79,7 @@ endif if (all (d >= 0)) - return + return; endif ## If we are here, there are negative inputs, so we need to diff --git a/scripts/strings/unicode2native.m b/scripts/strings/unicode2native.m index fdecee5af3..3eb6d9bce5 100644 --- a/scripts/strings/unicode2native.m +++ b/scripts/strings/unicode2native.m @@ -83,7 +83,7 @@ %!testif HAVE_ICONV <*64331> %! assert (! isempty (unicode2native ("abc", ""))); -# short character arrays with invalid UTF-8 +## short character arrays with invalid UTF-8 %!testif HAVE_ICONV <*63930> %! assert (unicode2native (char (230), 'windows-1252'), uint8 (63)); %!testif HAVE_ICONV <*63930> @@ -97,7 +97,7 @@ %! assert (unicode2native (char ([230, 10]), 'windows-1252'), %! uint8 ([63, 10])); -# target encoding with surrogates larger than a byte +## target encoding with surrogates larger than a byte %!testif HAVE_ICONV <*64139> %! assert (typecast (unicode2native ('abcde', %! ['utf-16', nthargout(3, 'computer'), 'e']), diff --git a/scripts/time/datevec.m b/scripts/time/datevec.m index b75f8fba75..bfc659769e 100644 --- a/scripts/time/datevec.m +++ b/scripts/time/datevec.m @@ -532,7 +532,7 @@ %!assert <*42241> (datevec ("08/15/2013", "mm"), [1900, 8, 0, 0, 0, 0]) %!assert <*42241> (datevec ("08ABC", "mm"), [1900, 8, 0, 0, 0, 0]) -# 6 mm/dd +## 6 mm/dd %!assert <*42241> (datevec ("08/15"), [yr, 8, 15, 0, 0, 0]) %!assert <*42241> (datevec ("08/15", "mm/dd"), [yr, 8, 15, 0, 0, 0]) %!assert <*42241> (datevec ("08/15/13", "mm/dd"), [yr, 8, 15, 0, 0, 0])