Skip to content

Commit

Permalink
maint: Style check m-files in scripts/ directory before 9.1 release.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Rik committed Nov 25, 2023
1 parent 39ec64a commit ce543cd
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion scripts/general/interp2.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion scripts/miscellaneous/license.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scripts/ode/private/integrate_adaptive.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions scripts/ode/private/ode_event_handler.m
Original file line number Diff line number Diff line change
Expand Up @@ -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,:);
Expand All @@ -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");
Expand Down
3 changes: 1 addition & 2 deletions scripts/ode/private/odemergeopts.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/ode/private/runge_kutta_interpolate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/optimization/sqp.m
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@
ub = globals.ub - x(ubidx, 1);
else
ub = [];
end
endif

res = [ci; lb; ub];

Expand Down
4 changes: 2 additions & 2 deletions scripts/pkg/private/build.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/plot/appearance/text.m
Original file line number Diff line number Diff line change
Expand Up @@ -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", ...
Expand All @@ -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, ...
Expand Down
1 change: 1 addition & 0 deletions scripts/plot/draw/quiver3.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@

endfunction


%!demo
%! clf;
%! colormap ("default");
Expand Down
6 changes: 3 additions & 3 deletions scripts/set/ismembertol.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) = [];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -225,6 +224,7 @@

endfunction


%!demo
%! ## Group random data
%! A = rand (1000, 2);
Expand Down
3 changes: 3 additions & 0 deletions scripts/signal/unwrap.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@

endif
endif

endfunction


Expand Down Expand Up @@ -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 = [];
Expand Down
4 changes: 2 additions & 2 deletions scripts/specfun/betainc.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions scripts/specfun/primes.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions scripts/statistics/cov.m
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
endswitch
endfunction


%!test
%! x = rand (10);
%! cx1 = cov (x);
Expand Down
5 changes: 3 additions & 2 deletions scripts/statistics/mad.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -119,6 +119,7 @@

endfunction


%!assert (mad (123), 0)
%!assert (mad (Inf), NaN)
%!assert (mad ([3, Inf]),Inf)
Expand Down
2 changes: 1 addition & 1 deletion scripts/statistics/mode.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
c(:) = NaN (1, 0);
endif
endif
return
return;
endif

if (dim > nd || sz(dim) == 1)
Expand Down
2 changes: 1 addition & 1 deletion scripts/strings/dec2bin.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
endif

if (all (d >= 0))
return
return;
endif

## If we are here, there are negative inputs, so we need to
Expand Down
4 changes: 2 additions & 2 deletions scripts/strings/unicode2native.m
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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']),
Expand Down
2 changes: 1 addition & 1 deletion scripts/time/datevec.m
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit ce543cd

Please sign in to comment.