# HG changeset patch # User Rik # Date 1664845615 25200 # Node ID a40c0b7aa3769cb4d37de2789d537d7e2bfd2c8d # Parent e78f6e2aa807f9a97930059410c3f8f5ff1b8165 maint: changes to follow Octave coding conventions. * NEWS.8.md: Wrap lines to 72 chars. * LSODE-opts.in: Use two spaces after sentence ending period. * LSODE.cc: Use minimum of two spaces between code and start of comment. * MemoizedFunction.m: Change copyright date to 2022 since this is the year it was accepted into core. Don't wrap error() lines to 80 chars. Use newlines to improve readability of switch statements. Use minimum of two spaces between code and start of comment. * del2.m, integral.m, interp1.m, interp2.m, griddata.m, inpolygon.m, waitbar.m, cubehelix.m, ind2x.m, importdata.m, textread.m, logm.m, lighting.m, shading.m, xticklabels.m, yticklabels.m, zticklabels.m, colorbar.m, meshc.m, print.m, __gnuplot_draw_axes__.m, struct2hdl.m, ppval.m, ismember.m, iqr.m: Use a space between comment character '#' and start of comment. Use hyphen for adjectives describing dimensions such as "1-D". * vectorize.m, ode23s.m: Use is_function_handle() instead of "isa (x, "function_handle")" for clarity and performance. * clearAllMemoizedCaches.m: Change copyright date to 2022 since this is the year it was accepted into core. Remove input validation which is done by interpreter. Use two newlines between end of code and start of BIST tests. * memoize.m: Change copyright date to 2022 since this is the year it was accepted into core. Re-wrap documentation to 80 chars. Use is_function_handle() instead of "isa (x, "function_handle")" for clarity and performance. Use two newlines between end of code and start of BIST tests. Use semicolon for assert statements within %!test block. Re-write BIST tests for input validation. * __memoize__.m: Change copyright date to 2022 since this is the year it was accepted into core. Use spaces in for statements to improve readability. * unique.m: Add FIXME note to commented BIST test * dec2bin.m: Remove stray newline at end of file. * triplequad.m: Reduce doubly-commented BIST syntax using "#%!#" to "#%!". * delaunayn.m: Use input variable names in error() statements. Use minimum of two spaces between code and start of comment. Use hyphen for describing dimensions. Use two newlines between end of code and start of BIST tests. Update BIST tests to pass. diff -r e78f6e2aa807 -r a40c0b7aa376 etc/NEWS.8.md --- a/etc/NEWS.8.md Sun Oct 02 09:00:28 2022 -0400 +++ b/etc/NEWS.8.md Mon Oct 03 18:06:55 2022 -0700 @@ -4,29 +4,30 @@ ### General improvements - Octave's libraries are now built using symbol visibility by default. -That means that less symbols are exported from these libraries. -Configure with `--disable-lib-visibility-flags` to export all symbols -(as in previous versions). + That means that less symbols are exported from these libraries. + Configure with `--disable-lib-visibility-flags` to export all symbols + (as in previous versions). - `filter` is now 5X faster, which also speeds up `deconv`, `fftfilt` -and `arma_rnd` by the same amount. + and `arma_rnd` by the same amount. - `integral` can now output a second argument passing the error -measurement used by the underlying integrator. + measurement used by the underlying integrator. - `perms` now accepts a second argument "unique" to return only unique -permutations for inputs with repeated elements. It is faster and takes -less memory to call `perms ('aaaabbbbcccc', "unique")` than to call -`unique (perms ('aaaabbbbcccc'), "rows")`. + permutations for inputs with repeated elements. It is faster and + takes less memory to call `perms ('aaaabbbbcccc', "unique")` than to + call `unique (perms ('aaaabbbbcccc'), "rows")`. - `quadgk` can now accept the `ArrayValued` input parameter to handle -array-valued input functions. + array-valued input functions. -- `delaunayn` now has consistent trivial simplex checking and removal for all -input dimensions, simplex checking 3D inputs is now vectorized, and >3D simplex -checking performance has been improved. Simplexes points are now ordered so -they will all have positive outward normal vectors. Input type checking has -also been added for improved error handling. +- `delaunayn` now has consistent trivial simplex checking and removal + for all input dimensions, simplex checking 3D inputs is now + vectorized, and >3D simplex checking performance has been improved. + Simplexes points are now ordered so they will all have positive + outward normal vectors. Input type checking has also been added for + improved error handling. ### Graphical User Interface @@ -37,8 +38,8 @@ * `"innerposition"` (equivalent to `"position"`) * `"windowstate"` (not yet implemented) -- Legend now features a new property `"itemhitfcn"`, allowing the execution of a -callback function when a legend item is clicked. +- Legend now features a new property `"itemhitfcn"`, allowing the + execution of a callback function when a legend item is clicked. ### Matlab compatibility diff -r e78f6e2aa807 -r a40c0b7aa376 liboctave/numeric/LSODE-opts.in --- a/liboctave/numeric/LSODE-opts.in Sun Oct 02 09:00:28 2022 -0400 +++ b/liboctave/numeric/LSODE-opts.in Mon Oct 03 18:06:55 2022 -0700 @@ -169,18 +169,18 @@ NAME = "jacobian type" DOC_ITEM A string specifying the type of Jacobian used with the stiff backward -differentiation formula (BDF) integration method. Valid values are +differentiation formula (BDF) integration method. Valid values are @table @asis @item @qcode{"full"} -The default. All partial derivatives are approximated or used from the +The default. All partial derivatives are approximated or used from the user-supplied Jacobian function. @item @qcode{"banded"} Only the diagonal and the number of lower and upper subdiagonals specified by the options @qcode{"lower jacobian subdiagonals"} and @qcode{"upper jacobian subdiagonals"}, respectively, are approximated or used from the user-supplied -Jacobian function. A user-supplied Jacobian function may set all other +Jacobian function. A user-supplied Jacobian function may set all other partial derivatives to arbitrary values. @item @qcode{"diagonal"} @@ -209,7 +209,7 @@ NAME = "lower jacobian subdiagonals" DOC_ITEM Number of lower subdiagonals used if option @qcode{"jacobian type"} is set to -@qcode{"banded"}. The default is zero. +@qcode{"banded"}. The default is zero. END_DOC_ITEM TYPE = "octave_idx_type" @@ -221,7 +221,7 @@ NAME = "upper jacobian subdiagonals" DOC_ITEM Number of upper subdiagonals used if option @qcode{"jacobian type"} is set to -@qcode{"banded"}. The default is zero. +@qcode{"banded"}. The default is zero. END_DOC_ITEM TYPE = "octave_idx_type" diff -r e78f6e2aa807 -r a40c0b7aa376 liboctave/numeric/LSODE.cc --- a/liboctave/numeric/LSODE.cc Sun Oct 02 09:00:28 2022 -0400 +++ b/liboctave/numeric/LSODE.cc Mon Oct 03 18:06:55 2022 -0700 @@ -131,9 +131,9 @@ user_jac_ignore_ml_mu = true; - m_iwork(0) = lower_jacobian_subdiagonals (); // 'ML' in dlsode.f + m_iwork(0) = lower_jacobian_subdiagonals (); // 'ML' in dlsode.f - m_iwork(1) = upper_jacobian_subdiagonals (); // 'MU' in dlsode.f + m_iwork(1) = upper_jacobian_subdiagonals (); // 'MU' in dlsode.f if (integration_method () == "stiff") { diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/+matlab/+lang/MemoizedFunction.m --- a/scripts/+matlab/+lang/MemoizedFunction.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/+matlab/+lang/MemoizedFunction.m Mon Oct 03 18:06:55 2022 -0700 @@ -1,6 +1,6 @@ ######################################################################## ## -## Copyright (C) 2021 The Octave Project Developers +## Copyright (C) 2022 The Octave Project Developers ## ## See the file COPYRIGHT.md in the top-level directory of this ## distribution or . @@ -23,7 +23,6 @@ ## ######################################################################## - classdef MemoizedFunction < handle properties (GetAccess = public, SetAccess = private) @@ -43,15 +42,16 @@ function this = MemoizedFunction (fcn_handle) if (! isa (fcn_handle, "function_handle")) - error (["matlab.lang.MemoizedFunction: FCN_HANDLE must be a ", ... - "function handle"]); + error ("matlab.lang.MemoizedFunction: FCN_HANDLE must be a function handle"); endif this.Function = fcn_handle; this.Cache = init_cache (); endfunction function varargout = subsref (this, s) + switch (s(1).type) + case "." switch (s(1).subs) case "Function" @@ -69,13 +69,14 @@ error ("matlab.lang.MemoizedFunction: unknown property '%s'", ... s(1).subs); endswitch + case "()" n_out = ifelse (nargout == 0, 1, nargout); if (! this.Enabled) [varargout{1:n_out}] = feval (this.Function, s(1).subs{:}); else cache_idx = []; - for i=1:numel (this.Cache.Inputs) + for i = 1:numel (this.Cache.Inputs) if (isequaln (this.Cache.Inputs{i}, s(1).subs) ... && isequal (this.Cache.Nargout(i), nargout)) cache_idx = i; @@ -88,13 +89,13 @@ this.Cache.HitCount(cache_idx) += 1; else [varargout{1:n_out}] = feval (this.Function, s(1).subs{:}); - n = numel(this.Cache.Inputs) + 1; + n = numel (this.Cache.Inputs) + 1; if (n > this.CacheSize) this.Cache.Inputs(1) = []; this.Cache.Nargout(1) = []; this.Cache.Outputs(1) = []; this.Cache.HitCount(1) = []; - n -= 1; # FIFO + n -= 1; # FIFO endif this.Cache.Inputs{n} = s(1).subs; this.Cache.Nargout(n) = nargout; @@ -103,38 +104,42 @@ this.Cache.TotalMisses += 1; endif endif + otherwise - error (["matlab.lang.MemoizedFunction: only '()' indexing is ", ... - "supported"]); + error ("matlab.lang.MemoizedFunction: only '()' indexing is supported"); + endswitch + if (numel (s) > 1) varargout{1} = subsref (varargout{1}, s(2:end)); endif + endfunction function this = subsasgn (this, s, val) + if (numel (s) > 1) - error (["matlab.lang.MemoizedFunction: only one level of indexing ", ... - "is supported"]); + error ("matlab.lang.MemoizedFunction: only one level of indexing is supported"); endif + switch (s(1).type) + case "." switch (s(1).subs) case "Function" - error (["matlab.lang.MemoizedFunction: property Function is ", ... - "read-only"]); + error ("matlab.lang.MemoizedFunction: property Function is read-only"); + case "Enabled" if (! isscalar (val) || ! (isnumeric (val) || islogical (val)) ... || ! isfinite (val)) - error (["matlab.lang.MemoizedFunction: Enabled must be a ", ... - "logical scalar"]); + error ("matlab.lang.MemoizedFunction: Enabled must be a logical scalar"); endif this.Enabled = logical (val); + case "CacheSize" if (! isscalar (val) || ! isnumeric (val) || ! isfinite (val) ... - || ceil (val) != val || val < 1) - error (["matlab.lang.MemoizedFunction: CacheSize must ", ... - "be a positive integer scalar"]) + || val < 1 || fix (val) != val) + error ("matlab.lang.MemoizedFunction: CacheSize must be a positive integer scalar"); endif this.CacheSize = double (val); n = numel(this.Cache.Inputs) - this.CacheSize; @@ -144,41 +149,44 @@ this.Cache.Outputs(1:n) = []; this.Cache.HitCount(1:n) = []; endif + otherwise error ("matlab.lang.MemoizedFunction: unknown property '%s'", ... s(1).subs); endswitch + otherwise - error (["matlab.lang.MemoizedFunction: only '.' indexing is ", ... - "supported for assigning values"]); + error ("matlab.lang.MemoizedFunction: only '.' indexing is supported for assigning values"); + endswitch + endfunction function clearCache (this) - if (nargin > 1 || nargout) - error ("matlab.lang.MemoizedFunction: Invalid call"); - endif this.Cache = init_cache (); endfunction function s = stats (this) + if (isempty (this.Cache.Inputs)) CacheHitRatePercent = 0; CacheOccupancyPercent = 0; MostHitCachedInput = []; else - CacheHitRatePercent = (this.Cache.TotalHits / ... - (this.Cache.TotalHits + this.Cache.TotalMisses)) * 100; - CacheOccupancyPercent = numel (this.Cache.Inputs) / this.CacheSize * 100; + CacheHitRatePercent = 100 * (this.Cache.TotalHits / + (this.Cache.TotalHits + this.Cache.TotalMisses)); + CacheOccupancyPercent = 100 * (numel (this.Cache.Inputs) + / this.CacheSize); [~, i] = max (this.Cache.HitCount); - MostHitCachedInput = struct ("Hits", this.Cache.HitCount(i), ... + MostHitCachedInput = struct ("Hits", this.Cache.HitCount(i), "Input", {this.Cache.Inputs{i}}); endif - s = struct (... - "Cache", this.Cache, ... - "MostHitCachedInput", MostHitCachedInput, ... - "CacheHitRatePercent", CacheHitRatePercent, ... - "CacheOccupancyPercent", CacheOccupancyPercent); + s = struct ( + "Cache", this.Cache, + "MostHitCachedInput", MostHitCachedInput, + "CacheHitRatePercent", CacheHitRatePercent, + "CacheOccupancyPercent", CacheOccupancyPercent); + endfunction function newobj = horzcat (varargin) @@ -186,7 +194,7 @@ endfunction function newobj = horzcat (varargin) - error ("matlab.lang.MemoizedFunction: concatenation is not allowed"); + error ("matlab.lang.MemoizedFunction: concatenation is not allowed"); endfunction endmethods @@ -194,10 +202,10 @@ endclassdef function cache = init_cache () -cache = struct ("Inputs", {{}}, ... - "Nargout", [], ... - "Outputs", {{}}, ... - "HitCount", [], ... - "TotalHits", 0, ... - "TotalMisses", 0); + cache = struct ("Inputs", {{}}, + "Nargout", [], + "Outputs", {{}}, + "HitCount", [], + "TotalHits", 0, + "TotalMisses", 0); endfunction diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/general/del2.m --- a/scripts/general/del2.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/general/del2.m Mon Oct 03 18:06:55 2022 -0700 @@ -311,7 +311,7 @@ %! assert (b(:,6), b(:,4)); %! assert (b(:,7:9), zeros (9,3)); -## 3D test +## 3-D test %!test %! a = zeros (9,9,9); %! a(5,5,5) = 1.0; diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/general/integral.m --- a/scripts/general/integral.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/general/integral.m Mon Oct 03 18:06:55 2022 -0700 @@ -321,7 +321,7 @@ %!assert (integral (@(x) [sin(x), cos(x)], 0, pi, "ArrayValued", 1, %! "Waypoints", [0.5]), [2, 0], 2*eps); -##test 2nd output +## Test 2nd output %!test <*62412> %! [~, err] = integral (@(x) ones (size (x)), 0, 1); # quadcc %! assert (err, 0, 5*eps); # err ~3e-16 diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/general/interp1.m --- a/scripts/general/interp1.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/general/interp1.m Mon Oct 03 18:06:55 2022 -0700 @@ -479,7 +479,7 @@ %! %-------------------------------------------------------- %! % red curve is left-continuous and blue is right-continuous at x = 2 -##FIXME: add test for N-d arguments here +## FIXME: add test for N-d arguments here ## For each type of interpolated test, confirm that the interpolated ## value at the knots match the values at the knots. Points away diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/general/interp2.m --- a/scripts/general/interp2.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/general/interp2.m Mon Oct 03 18:06:55 2022 -0700 @@ -231,9 +231,9 @@ Xsc = (XI - X(xidx)) ./ (diff (X)(xidx)); Ysc = (YI - Y(yidx)) ./ (diff (Y)(yidx)); - ## Get 2D index. + ## Get 2-D index. idx = sub2ind (size (a), yidx, xidx); - ## Dispose of the 1D indices at this point to save memory. + ## Dispose of the 1-D indices at this point to save memory. clear xidx yidx; ## Apply plane equation diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/general/triplequad.m --- a/scripts/general/triplequad.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/general/triplequad.m Mon Oct 03 18:06:55 2022 -0700 @@ -91,5 +91,5 @@ ## These tests are too expensive to run normally (~30 sec each). Disable them #%!assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadgk), pi^(3/2) * erf (1).^3, 1e-6) -#%!#assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadl), pi^(3/2) * erf (1).^3, 1e-6) -#%!#assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadv), pi^(3/2) * erf (1).^3, 1e-6) +#%!assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadl), pi^(3/2) * erf (1).^3, 1e-6) +#%!assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadv), pi^(3/2) * erf (1).^3, 1e-6) diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/geometry/delaunayn.m --- a/scripts/geometry/delaunayn.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/geometry/delaunayn.m Mon Oct 03 18:06:55 2022 -0700 @@ -70,7 +70,7 @@ ## NOTE: varargin options input validation is performed in __delaunayn__ if ((! isnumeric (pts)) || (ndims (pts) > 2)) - error ("delaunayn: input points must be a two dimensional numeric array."); + error ("delaunayn: input PTS must be a 2-dimensional numeric array"); endif ## Perform delaunay calculation using either default or specified options @@ -89,7 +89,7 @@ endif ## Begin check for and removal of trivial simplices - if (! isequal (T, 0)) # skip trivial simplex check if no simplexes + if (! isequal (T, 0)) # skip trivial simplex check if no simplexes if (isa (pts, "single")) tol = 1e3 * eps ("single"); @@ -108,23 +108,23 @@ ## of the two volumes means that the factor factorial(ndim+1) is dropped ## from volume calculations. - [nt, nd] = size (T); # nt = simplex count, nd = # of simplex points + [nt, nd] = size (T); # nt = simplex count, nd = # of simplex points dim = nd - 1; - ## calculate common origin edge vectors for each simplex (p2-p1,p3-p1,...) - ## store in 3D array such that: + ## Calculate common origin edge vectors for each simplex (p2-p1,p3-p1,...) + ## Store in 3-D array such that: ## rows = nt simplexes, cols = coordinates, pages = simplex edges edge_vecs = permute (reshape (pts(T(:, 2:nd), :).', [dim, nt, dim]), ... [2, 1, 3]) - pts(T(:, 1), :, ones (1, 1, dim)); - ## calculate orthogonal simplex volumes for comparison + ## Calculate orthogonal simplex volumes for comparison orthog_simplex_vols = sqrt (prod (sumsq (edge_vecs, 2), 3)); - ## calculate simplex volumes according to problem dimension + ## Calculate simplex volumes according to problem dimension if (nd == 3) ## 2-D: area = cross product of triangle edge vectors - vol = edge_vecs(:,1,1) .* edge_vecs(:,2,2)... - - edge_vecs(:,1,2) .* edge_vecs(:,2,1); + vol = edge_vecs(:,1,1) .* edge_vecs(:,2,2) ... + - edge_vecs(:,1,2) .* edge_vecs(:,2,1); elseif (nd == 4) ## 3-D: vol = scalar triple product [a.(b x c)] @@ -139,42 +139,41 @@ edge_vecs(:,2,2) .* edge_vecs(:,1,3)); else - ## 1D and >= 4-D: simplex 'volume' proportional to det|edge_vecs| + ## 1-D and >= 4-D: simplex 'volume' proportional to det|edge_vecs| - ## FIXME: Vectorize this for nD inputs without excessive memory impact - ## over __delaunayn__ itself, or move simplex checking into __delaunayn__. - ## Perhaps with an optimized page-wise determinant. - ## see bug #60818 for speed/memory improvement attempts and concerns. - + ## FIXME: Vectorize this for n-D inputs without excessive memory impact + ## over __delaunayn__ itself, or move simplex checking into __delaunayn__; + ## perhaps with an optimized page-wise determinant. + ## See bug #60818 for speed/memory improvement attempts and concerns. vol = zeros (nt, 1); - ##reshape so det can operate in dim1&2 + ## Reshape so det can operate in dim 1&2 edge_vecs = permute (edge_vecs, [3, 2, 1]); - ## calculate determinant for arbitrary problem dimension + ## Calculate determinant for arbitrary problem dimension for ii = 1:nt vol(ii) = det (edge_vecs(:, :, ii)); endfor endif - ## mark simplices with relative volume < tol for removal + ## Mark simplices with relative volume < tol for removal idx = (abs ((vol) ./ orthog_simplex_vols)) < tol; - ##Remove trivially small simplexes from T + ## Remove trivially small simplexes from T T(idx, :) = []; - ## ensure ccw node order for consistent outward normal (bug #53397) + ## Ensure CCW node order for consistent outward normal (bug #53397) ## simplest method of maintaining positive unit normal direction is to - ## reverse order of two nodes. this preserves 'nice' monotonic descending - ## node 1 ordering. Currently ignores 1D cases for compatibility. - - if ((dim > 1) && any (negvol = (vol (!idx) < 0))) + ## reverse order of two nodes; this preserves 'nice' monotonic descending + ## node 1 ordering. Currently ignores 1-D cases for compatibility. + if (dim > 1 && any (negvol = (vol(! idx) < 0))) T(negvol, [2, 3]) = T(negvol, [3, 2]); endif endif endfunction + ## Test 1-D input %!testif HAVE_QHULL %! assert (sortrows (sort (delaunayn ([1;2]), 2)), [1, 2]); @@ -216,7 +215,7 @@ %! x = [-1, 0; 0, 1; 1, 0; 0, -1; 0, 0]; %! y = delaunayn (x); %! edges = permute (reshape (x(y(:, 2:end), :).', [2, 4, 2]), [2, 1, 3]) - ... -%! x(y(:, 1), :, ones (1, 1, 2)); +%! x(y(:, 1), :, ones (1, 1, 2)); %! vol = edges(:,1,1) .* edges(:,2,2) - edges(:,1,2) .* edges(:,2,1); %! assert (all (vol >= 0)); @@ -225,7 +224,7 @@ %! x = [[-1, -1, 1, 0, -1]',[-1, 1, 1, 0, -1]',[0, 0, 0, 1, 1]']; %! y = delaunayn (x); %! edges = permute (reshape (x(y(:, 2:end), :).', [3, 2, 3]), [2, 1, 3]) - ... -%! x(y(:, 1), :, ones (1, 1, 3)); +%! x(y(:, 1), :, ones (1, 1, 3)); %! vol = edges(:,1,1) .* ... %! (edges(:,2,2) .* edges(:,3,3) - edges(:,3,2) .* edges(:,2,3)) ... %! - edges(:,2,1) .* ... @@ -236,8 +235,7 @@ ## Input validation tests %!error delaunayn () -%!error delaunayn ("abc") -%!error delaunayn ({1}) -%!error delaunayn (true) -%!error delaunayn (cat (3, [1 2 3], [4 5 6])) - +%!error delaunayn ("abc") +%!error delaunayn ({1}) +%!error delaunayn (true) +%!error delaunayn (ones (3,3,3)) diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/geometry/griddata.m --- a/scripts/geometry/griddata.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/geometry/griddata.m Mon Oct 03 18:06:55 2022 -0700 @@ -83,8 +83,9 @@ endif if (nargin > 6) - ## Current 2D implementation has nargin max = 6, since no triangulation - ## options are passed to the 2D algorithm. 3D algorithm requires nargin >=7 + ## Current 2-D implementation has nargin max = 6, since no triangulation + ## options are passed to the 2-D algorithm. + ## 3-D algorithm requires nargin >=7. if (nargout > 1) error ("griddata: only one output argument valid for 3-D interpolation"); @@ -92,7 +93,7 @@ rx = griddata3 (x, y, z, varargin{:}); else - ## for nargin 5 or 6, assign varargin terms to variables for 2D algorithm + ## for nargin 5 or 6, assign varargin terms to variables for 2-D algorithm xi = varargin{1}; yi = varargin{2}; diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/geometry/inpolygon.m --- a/scripts/geometry/inpolygon.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/geometry/inpolygon.m Mon Oct 03 18:06:55 2022 -0700 @@ -141,7 +141,7 @@ %! assert (in, [true, true, false]); %! assert (on, [true, false, false]); -## 3D array input +## 3-D array input %!test %! x = zeros (2, 2, 2); %! x(1, 1, 1) = 1; diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/gui/waitbar.m --- a/scripts/gui/waitbar.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/gui/waitbar.m Mon Oct 03 18:06:55 2022 -0700 @@ -139,7 +139,7 @@ ## Add createcancelbtn property addproperty ("createcancelbtn", hf, "figurebuttondownfcn"); ## FIXME: Can't add listener because of bug #55963. - #addlistener (hf, "createcancelbtn", {@updatecancelbutton, ax}); + ## addlistener (hf, "createcancelbtn", {@updatecancelbutton, ax}); if (! isempty (varargin)) set (hf, varargin{:}); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/image/cubehelix.m --- a/scripts/image/cubehelix.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/image/cubehelix.m Mon Oct 03 18:06:55 2022 -0700 @@ -87,7 +87,7 @@ endfunction -## A better demo of this colormap would be a 3D plot in NTSC instead of +## A better demo of this colormap would be a 3-D plot in NTSC instead of ## RGB values. That would really show what this colormap is about. %!demo %! ## Show the 'cubehelix' colormap profile and as an image diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/image/private/ind2x.m --- a/scripts/image/private/ind2x.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/image/private/ind2x.m Mon Oct 03 18:06:55 2022 -0700 @@ -28,9 +28,9 @@ function [x, map] = ind2x (caller, x, map) ## Check if X is an indexed image. - ## An indexed image is defined has having only 2D, and that's how Matlab - ## behaves. But we want to support ND images, so we will allow up to 4D - ## and check that the 3rd dimension is a singleton. + ## An indexed image is defined has having only 2 dimensions, and that's how + ## Matlab behaves. But we want to support N-D images, so we will allow up to + ## 4-D and check that the 3rd dimension is a singleton. if (all (ndims (x) != [2 4]) || size (x, 3) != 1 || iscomplex (x) || issparse (x) || ! (isfloat (x) && all (x(:) == fix (x(:))) diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/io/importdata.m --- a/scripts/io/importdata.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/io/importdata.m Mon Oct 03 18:06:55 2022 -0700 @@ -316,7 +316,7 @@ ## FIXME: This code should be redundant because dlmread was called ## with "emptyval", NA. Delete if there are no problems ## detected after some time. Commented out: 5/23/2020. - ##output.data(ridx, (col+1):end) = NA; + ## output.data(ridx, (col+1):end) = NA; missing_idx = missing_idx(1:col); endif text = fields(missing_idx); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/legacy/textread.m --- a/scripts/legacy/textread.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/legacy/textread.m Mon Oct 03 18:06:55 2022 -0700 @@ -266,7 +266,7 @@ warning ("off", "Octave:legacy-function", "local"); [varargout{1:max (nargout, 1)}] = strread (str, format, varargin{:}); - ## Hack to concatenate/reshape numeric output into 2D array (undocumented ML) + ## Hack to concatenate/reshape numeric output into 2-D array (undocumented ML) ## In ML this only works in case of an empty format string if (isempty (format)) ## Get number of fields per line. @@ -334,7 +334,7 @@ %! unlink (f); %! assert (a, d(2:7, 1), 1e-2); -## Test reading 2D matrix with empty format +## Test reading 2-D matrix with empty format %!test %! f = tempname (); %! d = rand (5, 2); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/legacy/vectorize.m --- a/scripts/legacy/vectorize.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/legacy/vectorize.m Mon Oct 03 18:06:55 2022 -0700 @@ -47,7 +47,7 @@ print_usage (); endif - if (isa (fcn, "function_handle")) + if (is_function_handle (fcn)) finfo = functions (fcn); if (! strcmp (finfo.type, "anonymous")) error ("vectorize: FCN must be a string or anonymous function handle"); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/linear-algebra/logm.m --- a/scripts/linear-algebra/logm.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/linear-algebra/logm.m Mon Oct 03 18:06:55 2022 -0700 @@ -143,7 +143,7 @@ ###### (SIAM, 2008.). ####################################################################### -##LOGM_PADE_PF Evaluate Pade approximant to matrix log by partial fractions. +## LOGM_PADE_PF Evaluate Pade approximant to matrix log by partial fractions. ## Y = LOGM_PADE_PF(A,M) evaluates the [M/M] Pade approximation to ## LOG(EYE(SIZE(A))+A) using a partial fraction expansion. diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/miscellaneous/clearAllMemoizedCaches.m --- a/scripts/miscellaneous/clearAllMemoizedCaches.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/miscellaneous/clearAllMemoizedCaches.m Mon Oct 03 18:06:55 2022 -0700 @@ -1,6 +1,6 @@ ######################################################################## ## -## Copyright (C) 2021 The Octave Project Developers +## Copyright (C) 2022 The Octave Project Developers ## ## See the file COPYRIGHT.md in the top-level directory of this ## distribution or . @@ -34,15 +34,12 @@ ## @seealso{memoize} ## @end deftypefn -function clearAllMemoizedCaches - - if (nargin || nargout) - print_usage (); - endif +function clearAllMemoizedCaches () __memoize__ (); endfunction + ## Mark file as being tested. No real test needed for this function. %!assert (1) diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/miscellaneous/memoize.m --- a/scripts/miscellaneous/memoize.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/miscellaneous/memoize.m Mon Oct 03 18:06:55 2022 -0700 @@ -1,6 +1,6 @@ ######################################################################## ## -## Copyright (C) 2021 The Octave Project Developers +## Copyright (C) 2022 The Octave Project Developers ## ## See the file COPYRIGHT.md in the top-level directory of this ## distribution or . @@ -26,8 +26,7 @@ ## -*- texinfo -*- ## @deftypefn {} {@var{mem_fcn_handle} =} memoize (@var{fcn_handle}) ## -## Create a memoized version @var{mem_fcn_handle} of function -## @var{fcn_handle}. +## Create a memoized version @var{mem_fcn_handle} of function @var{fcn_handle}. ## ## Each call to the memoized version @var{mem_fcn_handle} checks the inputs ## against an internally maintained table, and if the inputs have occurred @@ -35,12 +34,12 @@ ## itself instead of evaluating the full function again. This speeds up the ## execution of functions that are called with the same inputs multiple times. ## -## For example, here we take a slow user-written function named -## @code{slow_fcn} and memoize it to a new handle @code{cyc}. -## The first executions of both versions take the same time, but the subsequent -## executions of the memoized version returns the previously computed value, -## thus reducing 2.4 seconds of runtime to only 2.4 milliseconds. The final -## check verifies that the same result was returned from both versions. +## For example, here we take a slow user-written function named @code{slow_fcn} +## and memoize it to a new handle @code{cyc}. The first executions of both +## versions take the same time, but the subsequent executions of the memoized +## version returns the previously computed value, thus reducing 2.4 seconds of +## runtime to only 2.4 milliseconds. The final check verifies that the same +## result was returned from both versions. ## ## @example ## @group @@ -65,10 +64,11 @@ function mem_fcn_handle = memoize (fcn_handle) - if (nargin != 1 || nargout > 1) + if (nargin != 1) print_usage (); endif - if (! isa (fcn_handle, "function_handle")) + + if (! is_function_handle (fcn_handle)) error ("memoize: FCN_HANDLE must be a function handle"); endif @@ -76,13 +76,14 @@ endfunction + %!test %! fcn1 = memoize (@sin); %! assert (isa (fcn1, "matlab.lang.MemoizedFunction")); %! fcn1 (pi); %! fcn2 = memoize (@sin); %! fcn2 (2*pi); -%! assert (isequal (fcn1, fcn2)) +%! assert (isequal (fcn1, fcn2)); %!test %! fcn = memoize (@rand); @@ -100,8 +101,6 @@ %! clearCache (fcn); %! fcn.clearCache; -# Test input validation -%!error memoize (); -%!error memoize (1, 2); -%!error [a, b] = memoize (1); -%!error memoize (1); +## Test input validation +%!error memoize (); +%!error memoize (1); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/miscellaneous/private/__memoize__.m --- a/scripts/miscellaneous/private/__memoize__.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/miscellaneous/private/__memoize__.m Mon Oct 03 18:06:55 2022 -0700 @@ -1,6 +1,6 @@ ######################################################################## ## -## Copyright (C) 2021 The Octave Project Developers +## Copyright (C) 2022 The Octave Project Developers ## ## See the file COPYRIGHT.md in the top-level directory of this ## distribution or . @@ -26,7 +26,7 @@ ## -*- texinfo -*- ## @deftypefn {} {@var{mem_fcn_handle} =} __memoize__ (@var{fcn_handle}) ## @deftypefn {} {} __memoize__ () -## Internal function used by memoize. +## Internal function used by @code{memoize}. ## ## @seealso{clearAllMemoizedCaches, memoize} ## @end deftypefn @@ -36,7 +36,7 @@ if (nargin) - for i=1:numel (cached_mem_fcn_handle) + for i = 1:numel (cached_mem_fcn_handle) if (isequal (cached_mem_fcn_handle{i}.Function, fcn_handle)) mem_fcn_handle = cached_mem_fcn_handle{i}; return; @@ -48,7 +48,7 @@ else - for i=1:numel (cached_mem_fcn_handle) + for i = 1:numel (cached_mem_fcn_handle) clearCache (cached_mem_fcn_handle{i}); endfor diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/ode/ode23s.m --- a/scripts/ode/ode23s.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/ode/ode23s.m Mon Oct 03 18:06:55 2022 -0700 @@ -194,7 +194,7 @@ if (! isempty (odeopts.Mass) && isnumeric (odeopts.Mass)) havemasshandle = false; mass = odeopts.Mass; # constant mass - elseif (isa (odeopts.Mass, "function_handle")) + elseif (is_function_handle (odeopts.Mass)) havemasshandle = true; # mass defined by a function handle odeopts.Mass = feval (odeopts.Mass, trange(1), init, odeopts.funarguments{:}); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/appearance/lighting.m --- a/scripts/plot/appearance/lighting.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/appearance/lighting.m Mon Oct 03 18:06:55 2022 -0700 @@ -94,9 +94,9 @@ ## FIXME: This is the old, simple code. ## Unfortunately, it also lights contour plots which is not desirable. - ##hp = findobj (hax, "type", "patch"); - ##hs = findobj (hax, "type", "surface"); - ##hlist = [hp(:); hs(:)]; + ## hp = findobj (hax, "type", "patch"); + ## hs = findobj (hax, "type", "surface"); + ## hlist = [hp(:); hs(:)]; if (isempty (hlist)) return; diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/appearance/shading.m --- a/scripts/plot/appearance/shading.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/appearance/shading.m Mon Oct 03 18:06:55 2022 -0700 @@ -94,9 +94,9 @@ ## NOTE: This is the old, simple code. ## Unfortunately, it also shades contour plots which is not desirable. - ##hp = findobj (hax, "type", "patch"); - ##hs = findobj (hax, "type", "surface"); - ##hlist = [hp(:); hs(:)]; + ## hp = findobj (hax, "type", "patch"); + ## hs = findobj (hax, "type", "surface"); + ## hlist = [hp(:); hs(:)]; if (isempty (hlist)) return; diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/appearance/xticklabels.m --- a/scripts/plot/appearance/xticklabels.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/appearance/xticklabels.m Mon Oct 03 18:06:55 2022 -0700 @@ -102,7 +102,7 @@ endif - ## Convert any numeric elements to characters, make it a 1D cell array. + ## Convert any numeric elements to characters, make it a 1-D cell array. arg = cellfun (@num2str, arg, "UniformOutput", false)(:); ## Pad with blank cell entries if needed. diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/appearance/yticklabels.m --- a/scripts/plot/appearance/yticklabels.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/appearance/yticklabels.m Mon Oct 03 18:06:55 2022 -0700 @@ -102,7 +102,7 @@ endif - ## Convert any numeric elements to characters, make it a 1D cell array. + ## Convert any numeric elements to characters, make it a 1-D cell array. arg = cellfun (@num2str, arg, "UniformOutput", false)(:); ## Pad with blank cell entries if needed. diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/appearance/zticklabels.m --- a/scripts/plot/appearance/zticklabels.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/appearance/zticklabels.m Mon Oct 03 18:06:55 2022 -0700 @@ -102,7 +102,7 @@ endif - ## Convert any numeric elements to characters, make it a 1D cell array. + ## Convert any numeric elements to characters, make it a 1-D cell array. arg = cellfun (@num2str, arg, "UniformOutput", false)(:); ## Pad with blank cell entries if needed. diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/draw/colorbar.m --- a/scripts/plot/draw/colorbar.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/draw/colorbar.m Mon Oct 03 18:06:55 2022 -0700 @@ -294,7 +294,7 @@ addproperty ("tickdirection", hcb, "AxesTickdir", "in"); ## FIXME: Matlab uses just a scalar for ticklength, but axes already ## has a 2-element ticklength property which cannot be overridden. - ##addproperty ("ticklength", hcb, "double", 0.01); + ## addproperty ("ticklength", hcb, "double", 0.01); ## Add a pointer from colorbar directly to axes addproperty ("__axes_handle__", hcb, "handle", hax); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/draw/meshc.m --- a/scripts/plot/draw/meshc.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/draw/meshc.m Mon Oct 03 18:06:55 2022 -0700 @@ -78,7 +78,7 @@ hax = newplot (hax); ## FIXME: gnuplot does not support a filled surface and a - ## non-filled contour. 3D filled patches are also not supported. + ## non-filled contour. 3-D filled patches are also not supported. ## Thus, the facecolor will be transparent for the gnuplot backend. mesh_props = {"facecolor", "w", "edgecolor", "flat", ... "facelighting", "none", "edgelighting", "flat"}; diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/util/print.m --- a/scripts/plot/util/print.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/util/print.m Mon Oct 03 18:06:55 2022 -0700 @@ -790,7 +790,7 @@ ## Avoid a redraw since the figure should not have changed ## FIXME: Bug #57552, marker sizes, requires that redraw be done. - ##set (gcf, "__modified__", "off"); + ## set (gcf, "__modified__", "off"); ## Unlink temporary files for n = 1:numel (opts.unlink) diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/util/private/__gnuplot_draw_axes__.m --- a/scripts/plot/util/private/__gnuplot_draw_axes__.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m Mon Oct 03 18:06:55 2022 -0700 @@ -84,7 +84,7 @@ if (nd == 2 || all (mod (axis_obj.view, 90) == 0)) dr = dr(1) / dr(2); else - ## FIXME: need to properly implement 3D + ## FIXME: need to properly implement 3-D dr = mean (dr(1:2)) / dr(3); endif else @@ -95,7 +95,7 @@ if (nd == 2 || all (mod (axis_obj.view, 90) == 0)) x = [1, 1]; else - ## 3D plots need to be sized down to fit in the window. + ## 3-D plots need to be sized down to fit in the window. x = 1.0 ./ sqrt ([2, 2.5]); endif fprintf (plot_stream, "set tmargin screen %.15g;\n", @@ -1422,7 +1422,7 @@ endwhile - ## This is needed to prevent warnings for rotations in 3D plots, while + ## This is needed to prevent warnings for rotations in 3-D plots, while ## allowing colorbars with contours. if (nd == 2 || (data_idx > 1 && ! view_map)) fputs (plot_stream, "set pm3d implicit;\n"); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/plot/util/struct2hdl.m --- a/scripts/plot/util/struct2hdl.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/plot/util/struct2hdl.m Mon Oct 03 18:06:55 2022 -0700 @@ -395,10 +395,10 @@ function [h, sout] = createscatter (s, par) if (isempty (s.properties.zdata)) - ## 2D scatter + ## 2-D scatter h = scatter (s.properties.xdata, s.properties.ydata); else - ## 3D scatter + ## 3-D scatter h = scatter3 (s.properties.xdata, s.properties.ydata, s.properties.zdata); endif @@ -542,7 +542,7 @@ "udatasource", "vdatasource", "wdatasource"}); elseif (isfield (fields, "format")) - ##errorbar + ## errorbar form = s.properties.format; xdata = s.properties.xdata; ydata = s.properties.ydata; @@ -606,7 +606,7 @@ xdata = []; ydata = []; - ##build x/y matrix + ## Build x/y matrix nbar = length (bargroup); tmp = struct ("handle", NaN, "type", "", "children", [], "special", []); for ii = 1:(nbar - 1) diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/polynomial/ppval.m --- a/scripts/polynomial/ppval.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/polynomial/ppval.m Mon Oct 03 18:06:55 2022 -0700 @@ -61,7 +61,7 @@ P = reshape (P, [d, n * k]); P = shiftdim (P, nd); P = reshape (P, [n, k, d]); - Pidx = P(idx(:), :); # 2D matrix size: x = coefs*prod (d), y = prod (sxi) + Pidx = P(idx(:), :); # 2-D matrix size: x = coefs*prod (d), y = prod (sxi) if (isvector (xi)) Pidx = reshape (Pidx, [xn, k, d]); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/set/ismember.m --- a/scripts/set/ismember.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/set/ismember.m Mon Oct 03 18:06:55 2022 -0700 @@ -122,7 +122,7 @@ by_rows = any (strcmp ("rows", varargin)); ## FIXME: uncomment if bug #56692 is addressed. - ##optlegacy = any (strcmp ("legacy", varargin)); + ## optlegacy = any (strcmp ("legacy", varargin)); if (! by_rows) s = s(:); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/set/unique.m --- a/scripts/set/unique.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/set/unique.m Mon Oct 03 18:06:55 2022 -0700 @@ -305,6 +305,7 @@ %! [y,i,~] = unique ([4,4,2,2,2,3,1], "stable"); %! assert (y, [4,2,3,1]); %! assert (i, [1;3;6;7]); +%! ## FIXME: 'j' input not calculated with stable %! ##assert (j, []); %!test @@ -337,6 +338,7 @@ %! [y,i,~] = unique (A, "rows", "stable"); %! assert (y, [4,5,6; 1,2,3]); %! assert (A(i,:), y); +%! ## FIXME: 'j' output not calculated correctly with "stable" %! ##assert (y(j,:), A); ## Test "legacy" option diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/statistics/iqr.m --- a/scripts/statistics/iqr.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/statistics/iqr.m Mon Oct 03 18:06:55 2022 -0700 @@ -95,7 +95,7 @@ && all (dim > 0) && all (rem (dim, 1) == 0)) if (((num_vecdims = numel (dim)) > 1) && all (diff (sort (dim)))) - ## DIM must be 1D and non repeating. + ## DIM must be 1-D and non repeating. ## Detect trivial case of DIM being all dimensions (same as "all"). highest_dim = (max (nd, max (dim))); diff -r e78f6e2aa807 -r a40c0b7aa376 scripts/strings/dec2bin.m --- a/scripts/strings/dec2bin.m Sun Oct 02 09:00:28 2022 -0400 +++ b/scripts/strings/dec2bin.m Mon Oct 03 18:06:55 2022 -0700 @@ -150,4 +150,3 @@ ## Test input validation %!error dec2bin () -