changeset 20937:3b2cc6ef0624

use numfields (x) instead of numel (fieldnames (x)) * inputParser.m, fileattrib.m, odeset.m: Use numfields (x) instead of numel (fieldnames (x)).
author John W. Eaton <jwe@octave.org>
date Fri, 18 Dec 2015 15:55:36 -0500
parents 80dd7b3529ee
children aac911d8847b
files scripts/general/inputParser.m scripts/miscellaneous/fileattrib.m scripts/ode/odeset.m
diffstat 3 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/general/inputParser.m	Wed Dec 16 21:13:47 2015 -0500
+++ b/scripts/general/inputParser.m	Fri Dec 18 15:55:36 2015 -0500
@@ -285,8 +285,8 @@
     function addRequired (this, name, val = inputParser.def_val)
       if (nargin < 2 || nargin > 3)
         print_usage ();
-      elseif (numel (this.Optional) || numel (fieldnames (this.ParamValue))
-              || numel (fieldnames (this.Switch)))
+      elseif (numel (this.Optional) || numfields (this.ParamValue)
+              || numfields (this.Switch))
         error (["inputParser.addRequired: can't have a Required argument " ...
                 "after Optional, ParamValue, or Switch"]);
       endif
@@ -297,8 +297,7 @@
     function addOptional (this, name, def, val = inputParser.def_val)
       if (nargin < 3 || nargin > 4)
         print_usage ();
-      elseif (numel (fieldnames (this.ParamValue))
-              || numel (fieldnames (this.Switch)))
+      elseif (numfields (this.ParamValue) || numfields (this.Switch))
         error (["inputParser.Optional: can't have Optional arguments " ...
                 "after ParamValue or Switch"]);
       endif
--- a/scripts/miscellaneous/fileattrib.m	Wed Dec 16 21:13:47 2015 -0500
+++ b/scripts/miscellaneous/fileattrib.m	Fri Dec 18 15:55:36 2015 -0500
@@ -154,7 +154,7 @@
 %! [status, attr] = fileattrib (P_tmpdir ());
 %! assert (status);
 %! assert (isstruct (attr));
-%! assert (numel (fieldnames (attr)), 14);
+%! assert (numfields (attr), 14);
 %! assert (attr.Name, P_tmpdir ());
 %! assert (attr.directory);
 %! if (ispc ())
--- a/scripts/ode/odeset.m	Wed Dec 16 21:13:47 2015 -0500
+++ b/scripts/ode/odeset.m	Fri Dec 18 15:55:36 2015 -0500
@@ -269,7 +269,7 @@
 %!xtest
 %! odeoptA = odeset ();
 %! assert (isstruct (odeoptA));
-%! assert (numel (fieldnames (odeoptA)), 23);
+%! assert (numfields (odeoptA), 23);
 %! assert (all (structfun ("isempty", odeoptA)));
 
 %!shared odeoptB, odeoptC