changeset 28724:08049eff8733

maint: merge stable to default.
author Rik <rik@octave.org>
date Fri, 11 Sep 2020 20:04:07 -0700
parents 7ae10fadd008 (current diff) dd9efd873596 (diff)
children 533993e3f115
files
diffstat 18 files changed, 481 insertions(+), 352 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/miscellaneous/mustBeFinite.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeFinite.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,33 +26,42 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeFinite (@var{x})
 ##
-## Requires that input @var{x} is finite.
+## Require that input @var{x} is finite.
 ##
-## Raises an error if any element of the input @var{x} is not finite, as
+## Raise an error if any element of the input @var{x} is not finite, as
 ## determined by @code{isfinite (x)}.
 ##
+## @seealso{mustBeNonNan, isfinite}
 ## @end deftypefn
 
 function mustBeFinite (x)
-  tf = isfinite (x);
-  if ! all (tf)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  tf = isfinite (x(:));
+  if (! all (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (!tf);
-    error ("%s must be finite; got Infs in %d elements: indexes %s", ...
-      label, numel (ix_bad), mat2str (ix_bad));
+    bad_idx = find (! tf);
+    error ("%s must be finite; found %d non-finite elements: indexes %s",
+           label, numel (bad_idx), mat2str (bad_idx));
   endif
+
 endfunction
 
+
 %!test
 %! mustBeFinite ([]);
 %! mustBeFinite (42);
 %! mustBeFinite (-100:.1:100);
-%! mustBeFinite (int32(42))
+%! mustBeFinite (int32 (42));
 
-%!error mustBeFinite ();
-%!error mustBeFinite (Inf);
-%!error mustBeFinite ([1 2 3 Inf]);
-%!error mustBeFinite ([-Inf -1 0 1]);
+%!error <Invalid call> mustBeFinite ()
+%!error <found 1 non-finite> mustBeFinite (Inf)
+%!error <indexes 4> mustBeFinite ([1 2 3 Inf])
+%!error <indexes 1> mustBeFinite ([-Inf -1 0 1])
+%!error <indexes 1> mustBeFinite ([NaN -1])
--- a/scripts/miscellaneous/mustBeGreaterThan.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeGreaterThan.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,38 +26,48 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeGreaterThan (@var{x}, @var{c})
 ##
-## Requires that input @var{x} is greater than @var{c}.
+## Require that input @var{x} is greater than @var{c}.
 ##
-## Raises an error if any element of the input @var{x} is not greater than
+## Raise an error if any element of the input @var{x} is not greater than
 ## @var{c}, as determined by @code{@var{x} > @var{c}}.
 ##
+## @seealso{mustBeGreaterThanOrEqual, mustBeLessThan, gt}
 ## @end deftypefn
 
 function mustBeGreaterThan (x, c)
-  tf = x > c;
-  tf = tf(:);
-  if ! all (tf)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  tf = (x > c)(:);
+  if (! all (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
+    bad_idx = find (! tf);
     try
-      bad = x(ix_bad);
-      errmsg = sprintf ("%s must be greater than %f; got %d elements that were not: values %s", ...
-        label, c, numel (ix_bad), mat2str (bad));
-    catch err
-      errmsg = sprintf ("%s must be greater than %f; got %d elements that were not: indexes %s", ...
-        label, c, numel (ix_bad), mat2str (ix_bad));
+      bad_val = x(bad_idx);
+      errmsg = sprintf ("%s must be greater than %f; found %d elements that were not: values %s", ...
+                        label, c, numel (bad_idx), mat2str (bad_val));
+    catch
+      errmsg = sprintf ("%s must be greater than %f; found %d elements that were not: indexes %s", ...
+                        label, c, numel (bad_idx), mat2str (bad_idx));
     end_try_catch
     error (errmsg);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeGreaterThan (42, 0)
-%! mustBeGreaterThan (Inf, 9999)
+%! mustBeGreaterThan (42, 0);
+%! mustBeGreaterThan (Inf, 9999);
 
-%!error mustBeGreaterThan (42, 42)
-%!error mustBeGreaterThan (Inf, Inf)
-%!error mustBeGreaterThan (NaN, 0)
+%!error <Invalid call> mustBeGreaterThan ()
+%!error <Invalid call> mustBeGreaterThan (1)
+%!error <Invalid call> mustBeGreaterThan (1,2,3)
+%!error <input must be greater than 42> mustBeGreaterThan (42, 42)
+%!error <found 1 elements that were not> mustBeGreaterThan (Inf, Inf)
+%!error <must be greater than 0> mustBeGreaterThan (NaN, 0)
--- a/scripts/miscellaneous/mustBeGreaterThanOrEqual.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeGreaterThanOrEqual.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,42 +26,49 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeGreaterThanOrEqual (@var{x}, @var{c})
 ##
-## Requires that input @var{x} is greater than or equal to @var{c}.
+## Require that input @var{x} is greater than or equal to @var{c}.
 ##
-## Raises an error if any element of the input @var{x} is not greater than
+## Raise an error if any element of the input @var{x} is not greater than
 ## or equal to @var{c}, as determined by @code{@var{x} >= @var{c}}.
 ##
+## @seealso{mustBeGreaterThan, mustBeLessThanOrEqual, ge}
 ## @end deftypefn
 
 function mustBeGreaterThanOrEqual (x, c)
-  tf = x >= c;
-  tf = tf(:);
-  if ! all (tf)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  tf = (x >= c)(:);
+  if (! all (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
+    bad_idx = find (! tf);
     try
-      bad = x(ix_bad);
-      errmsg = sprintf ( ...
-        "%s must be greater than or equal to %f; got %d elements that were not: values %s", ...
-        label, c, numel (ix_bad), mat2str (bad));
-    catch err
-      errmsg = sprintf ( ...
-        "%s must be greater than or equal to %f; got %d elements that were not: indexes %s", ...
-        label, c, numel (ix_bad), mat2str (ix_bad));
+      bad_val = x(bad_idx);
+      errmsg = sprintf ("%s must be greater than or equal to %f; found %d elements that were not: values %s", ...
+                        label, c, numel (bad_idx), mat2str (bad_val));
+    catch
+      errmsg = sprintf ("%s must be greater than or equal to %f; found %d elements that were not: indexes %s", ...
+                        label, c, numel (bad_idx), mat2str (bad_idx));
     end_try_catch
     error (errmsg);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeGreaterThanOrEqual (42, 0)
-%! mustBeGreaterThanOrEqual (Inf, 9999)
-%! mustBeGreaterThanOrEqual (42, 42)
-%! mustBeGreaterThanOrEqual (Inf, Inf)
+%! mustBeGreaterThanOrEqual (42, 0);
+%! mustBeGreaterThanOrEqual (Inf, 9999);
+%! mustBeGreaterThanOrEqual (42, 42);
+%! mustBeGreaterThanOrEqual (Inf, Inf);
 
-%!error mustBeGreaterThanOrEqual ()
-%!error mustBeGreaterThanOrEqual (42)
-%!error mustBeGreaterThanOrEqual (NaN, 0)
+%!error <Invalid call> mustBeGreaterThanOrEqual ()
+%!error <Invalid call> mustBeGreaterThanOrEqual (1)
+%!error <Invalid call> mustBeGreaterThanOrEqual (1,2,3)
+%!error <must be greater than or equal to 2> mustBeGreaterThanOrEqual (1, 2)
+%!error <must be greater than or equal to 0> mustBeGreaterThanOrEqual (NaN, 0)
--- a/scripts/miscellaneous/mustBeInteger.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeInteger.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,45 +26,57 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeInteger (@var{x})
 ##
-## Requires that input @var{x} is integer-valued (but not necessarily
+## Require that input @var{x} is integer-valued (but not necessarily
 ## integer-typed).
 ##
-## Raises an error if any element of the input @var{x} is not a finite,
+## Raise an error if any element of the input @var{x} is not a finite,
 ## real, integer-valued numeric value, as determined by various checks.
 ##
+## @seealso{mustBeNumeric}
 ## @end deftypefn
 
 function mustBeInteger (x)
-  if isinteger (x) || islogical (x)
-    return
+
+  if (nargin != 1)
+    print_usage ();
   endif
+
+  if (isinteger (x) || islogical (x))
+    return;
+  endif
+
   but = [];
-  if ! isnumeric (x)
-    but = sprintf ("it was non-numeric (got a %s)", class (x));
-  elseif any (! isfinite (x))
-    but = "there were Inf values";
-  elseif ! isreal (x)
+  if (! isnumeric (x))
+    but = sprintf ("it was non-numeric (found a %s)", class (x));
+  elseif (! isreal (x))
     but = "it was complex";
-  elseif ! all (floor (x) == x)
+  elseif (any (! isfinite (x)))
+    but = "there were non-finite values";
+  elseif (any (x != fix (x)))
     but = "it had fractional values in some elements";
   end
-  if ! isempty (but)
+
+  if (! isempty (but))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
     error ("%s must be integer-valued; but %s", label, but);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeInteger ([])
-%! mustBeInteger (42)
-%! mustBeInteger (1:1000)
-%! mustBeInteger (int32(42))
+%! mustBeInteger ([]);
+%! mustBeInteger (42);
+%! mustBeInteger (1:1000);
+%! mustBeInteger (int32 (42));
+%! mustBeInteger (true);
 
-%!error mustBeInteger ()
-%!error mustBeInteger (1.23)
-%!error mustBeInteger ([1 2 3 4.4])
-%!error mustBeInteger (Inf)
-%!error mustBeInteger (NaN)
+%!error <Invalid call> mustBeInteger ()
+%!error <it was non-numeric> mustBeInteger ("Hello World")
+%!error <it was complex> mustBeInteger ([1, 2i])
+%!error <there were non-finite values> mustBeInteger (Inf)
+%!error <there were non-finite values> mustBeInteger (NaN)
+%!error <it had fractional values> mustBeInteger ([1 2 3 4.4])
--- a/scripts/miscellaneous/mustBeLessThan.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeLessThan.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,44 +26,51 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeLessThan (@var{x}, @var{c})
 ##
-## Requires that input @var{x} is less than @var{c}.
+## Require that input @var{x} is less than @var{c}.
 ##
-## Raises an error if any element of the input @var{x} is not less than
+## Raise an error if any element of the input @var{x} is not less than
 ## @var{c}, as determined by @code{@var{x} < @var{c}}.
 ##
+## @seealso{mustBeLessThanOrEqual, mustBeGreaterThan, lt}
 ## @end deftypefn
 
 function mustBeLessThan (x, c)
-  tf = x < c;
-  tf = tf(:);
-  if ! all (tf)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  tf = (x < c)(:);
+  if (! all (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
+    bad_idx = find (! tf);
     try
-      bad = x(ix_bad);
-      errmsg = sprintf ( ...
-        "%s must be less than %f; got %d elements that were not: values %s", ...
-        label, c, numel (ix_bad), mat2str (bad));
-    catch err
-      errmsg = sprintf ( ...
-        "%s must be less than %f; got %d elements that were not: indexes %s", ...
-        label, c, numel (ix_bad), mat2str (ix_bad));
+      bad_val = x(bad_idx);
+      errmsg = sprintf ("%s must be less than %f; found %d elements that were not: values %s", ...
+                        label, c, numel (bad_idx), mat2str (bad_val));
+    catch
+      errmsg = sprintf ("%s must be less than %f; found %d elements that were not: indexes %s", ...
+                        label, c, numel (bad_idx), mat2str (bad_idx));
     end_try_catch
     error (errmsg);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeLessThan (0, 1)
-%! mustBeLessThan (-Inf, 42)
-%! mustBeLessThan (42, Inf)
-%! mustBeLessThan (1:41, 42)
+%! mustBeLessThan (0, 1);
+%! mustBeLessThan (-Inf, 42);
+%! mustBeLessThan (42, Inf);
+%! mustBeLessThan (1:41, 42);
 
-%!error mustBeLessThan ()
-%!error mustBeLessThan (1, 0)
-%!error mustBeLessThan (1, 1)
-%!error mustBeLessThan (Inf, Inf)
-%!error mustBeLessThan (1:42, 42)
+%!error <Invalid call> mustBeLessThan ()
+%!error <Invalid call> mustBeLessThan (1)
+%!error <Invalid call> mustBeLessThan (1,2,3)
+%!error <must be less than 0> mustBeLessThan (1, 0)
+%!error <must be less than 1> mustBeLessThan (1, 1)
+%!error <must be less than Inf> mustBeLessThan (Inf, Inf)
+%!error <must be less than 42> mustBeLessThan (1:42, 42)
--- a/scripts/miscellaneous/mustBeLessThanOrEqual.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeLessThanOrEqual.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,45 +26,51 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeLessThanOrEqual (@var{x}, @var{c})
 ##
-## Requires that input is less than or equal to a given value.
+## Require that input is less than or equal to a given value.
 ##
-## Raises an error if any element of the input @var{x} is not less than
+## Raise an error if any element of the input @var{x} is not less than
 ## or equal to @var{c}, as determined by @code{@var{x} <= @var{c}}.
 ##
+## @seealso{mustBeLessThan, mustBeGreaterThanOrEqual, le}
 ## @end deftypefn
 
 function mustBeLessThanOrEqual (x, c)
-  tf = x <= c;
-  tf = tf(:);
-  if ! all (tf)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  tf = (x <= c)(:);
+  if (! all (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
+    bad_idx = find (! tf);
     try
-      bad = x(ix_bad);
-      errmsg = sprintf ( ...
-        "%s must be less than or equal to %f; got %d elements that were not: values %s", ...
-        label, c, numel (ix_bad), mat2str (bad));
-    catch err
-      errmsg = sprintf ( ...
-        "%s must be less than or equal to %f; got %d elements that were not: indexes %s", ...
-        label, c, numel (ix_bad), mat2str (ix_bad));
+      bad_val = x(bad_idx);
+      errmsg = sprintf ("%s must be less than or equal to %f; found %d elements that were not: values %s", ...
+                        label, c, numel (bad_idx), mat2str (bad_val));
+    catch
+      errmsg = sprintf ("%s must be less than or equal to %f; found %d elements that were not: indexes %s", ...
+                        label, c, numel (bad_idx), mat2str (bad_idx));
     end_try_catch
     error (errmsg);
   endif
+
 endfunction
 
 
 %!test
-%! mustBeLessThanOrEqual (0, 1)
-%! mustBeLessThanOrEqual (-Inf, 42)
-%! mustBeLessThanOrEqual (42, Inf)
-%! mustBeLessThanOrEqual (1:41, 42)
-%! mustBeLessThanOrEqual (1:42, 42)
-%! mustBeLessThanOrEqual (1, 1)
-%! mustBeLessThanOrEqual (Inf, Inf)
+%! mustBeLessThanOrEqual (0, 1);
+%! mustBeLessThanOrEqual (-Inf, 42);
+%! mustBeLessThanOrEqual (42, Inf);
+%! mustBeLessThanOrEqual (1:41, 42);
+%! mustBeLessThanOrEqual (1:42, 42);
+%! mustBeLessThanOrEqual (1, 1);
+%! mustBeLessThanOrEqual (Inf, Inf);
 
-%!error mustBeLessThanOrEqual ()
-%!error mustBeLessThanOrEqual (1, 0)
+%!error <Invalid call> mustBeLessThanOrEqual ()
+%!error <Invalid call> mustBeLessThanOrEqual (1)
+%!error <Invalid call> mustBeLessThanOrEqual (1,2,3)
+%!error <must be less than or equal to 0> mustBeLessThanOrEqual (1, 0)
--- a/scripts/miscellaneous/mustBeMember.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeMember.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,40 +26,50 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeMember (@var{x}, @var{valid})
 ##
-## Requires that input @var{x} is a member of a set of given valid values.
+## Require that input @var{x} is a member of a set of given valid values.
 ##
-## Raises an error if any element of the input @var{x} is not a member
-## of @var{valid}, as determined by @code{ismember (@var{x})}.
+## Raise an error if any element of the input @var{x} is not a member
+## of the set @var{valid}, as determined by @code{ismember (@var{x})}.
 ##
-## Note that char inputs may behave weirdly, because of the interaction
-## between chars and cellstrings when calling ismember() on them.  But it
-## will probably "do what you mean" if you just use it naturally.
+## Programming Note: char inputs may behave strangely because of the
+## interaction between chars and cellstrings when calling @code{ismember} on
+## them.  But it will probably "do what you mean" if you just use it naturally.
+## To guarantee operation, convert all char arrays to cellstrings with
+## @code{cellstr}.
 ##
+## @seealso{mustBeNonempty, ismember}
 ## @end deftypefn
 
 function mustBeMember (x, valid)
-  tf = ismember (x, valid);
-  if ! all (tf)
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  tf = ! (ismember (x, valid))(:);
+  if (any (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    n_bad = numel (find (! tf));
-    # TODO: Fancy inclusion of bad & valid values in the error message.
-    # Probably use mat2str() in a try/catch for that.
-    error ( ...
-      "%s must be one of the specified valid values; got %d elements that weren't", ...
-      label, n_bad);
+    n_bad = numel (find (tf));
+    # FIXME: Fancy inclusion of bad_val & valid values in the error message.
+    #        Probably use mat2str() in a try/catch for that.
+    error ("%s must be one of the specified valid values; found %d elements that were not", ...
+           label, n_bad);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeMember (42, 38:50)
-%! mustBeMember ('foo', {'foo', 'bar', 'baz'})
-%! mustBeMember (38:42, 37:43)
-%! mustBeMember ({'foo','bar'}, {'foo', 'bar', 'baz'})
+%! mustBeMember (42, 38:50);
+%! mustBeMember ("foo", {"foo", "bar", "baz"});
+%! mustBeMember (38:42, 37:43);
+%! mustBeMember ({"foo","bar"}, {"foo", "bar", "baz"});
 
-%!error mustBeMember ()
-%!error mustBeMember (42)
-%!error mustBeMember (42, 1:5)
-%!error mustBeMember ('nope', {'foo', 'bar', 'baz'})
+%!error <Invalid call> mustBeMember ()
+%!error <Invalid call> mustBeMember (1)
+%!error <Invalid call> mustBeMember (1,2,3)
+%!error <found 1 elements> mustBeMember ([1, 42], 1:5)
+%!error <found 1 elements> mustBeMember ("nope", {"foo", "bar", "baz"})
--- a/scripts/miscellaneous/mustBeNegative.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeNegative.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,41 +26,46 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeNegative (@var{x})
 ##
-## Requires that input @var{x} is negative.
+## Require that input @var{x} is negative.
 ##
-## Raises an error if any element of the input @var{x} is not negative, as
+## Raise an error if any element of the input @var{x} is not negative, as
 ## determined by @code{@var{x} < 0}.
 ##
+## @seealso{mustBeNonnegative}
 ## @end deftypefn
 
 function mustBeNegative (x)
-  tf = x < 0;
-  tf = tf(:);
-  if ! all (tf)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  tf = (x < 0)(:);
+  if (! all (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
+    bad_idx = find (! tf);
     try
-      bad = x(ix_bad);
-      errmsg = sprintf ( ...
-        "%s must be negative; got %d elements that were not: values %s", ...
-        label, numel (ix_bad), mat2str (bad));
-    catch err
-      errmsg = sprintf ( ...
-        "%s must be negative; got %d elements that were not: indexes %s", ...
-        label, numel (ix_bad), mat2str (ix_bad));
+      bad_val = x(bad_idx);
+      errmsg = sprintf ("%s must be negative; found %d elements that were not: values %s", ...
+                        label, numel (bad_idx), mat2str (bad_val));
+    catch
+      errmsg = sprintf ("%s must be negative; found %d elements that were not: indexes %s", ...
+                        label, numel (bad_idx), mat2str (bad_idx));
     end_try_catch
     error (errmsg);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeNegative (-42)
-%! mustBeNegative ([])
-%! mustBeNegative (-10:-2)
+%! mustBeNegative ([]);
+%! mustBeNegative (-42);
+%! mustBeNegative (-10:-2);
 
-%!error mustBeNegative ()
-%!error mustBeNegative (42)
-%!error mustBeNegative (-5:5)
+%!error <Invalid call> mustBeNegative ()
+%!error <found 1 elements> mustBeNegative ([-1, 42])
+%!error <found 6 elements> mustBeNegative (-5:5)
--- a/scripts/miscellaneous/mustBeNonNan.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeNonNan.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,36 +26,42 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeNonNan (@var{x})
 ##
-## Requires that input @var{x} is non-NaN.
+## Require that input @var{x} is non-@code{NaN}.
 ##
-## Raises an error if any element of the input @var{x} is NaN, as determined
-## by @code{isnan (@var{x})}.
+## Raise an error if any element of the input @var{x} is @code{NaN}, as
+## determined by @code{isnan (@var{x})}.
 ##
+## @seealso{mustBeFinite, mustBeNonempty, isnan}
 ## @end deftypefn
 
 function mustBeNonNan (x)
-  tf = ! isnan (x);
-  tf = tf(:);
-  if ! all (tf)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  tf = isnan (x(:));
+  if (any (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
-    errmsg = sprintf ( ...
-      "%s must be non-NaN; got %d elements that were not: indexes %s", ...
-      label, numel (ix_bad), mat2str (ix_bad));
+    bad_idx = find (tf);
+    errmsg = sprintf ("%s must be non-NaN; found %d elements that were not: indexes %s", ...
+                      label, numel (bad_idx), mat2str (bad_idx));
     error (errmsg);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeNonNan (42)
-%! mustBeNonNan ('foo')
-%! mustBeNonNan (1:10)
-%! mustBeNonNan (Inf)
-%! mustBeNonNan (-Inf)
+%! mustBeNonNan (42);
+%! mustBeNonNan ("foo");
+%! mustBeNonNan (1:10);
+%! mustBeNonNan (Inf);
+%! mustBeNonNan (-Inf);
 
-%!error mustBeNonNan ()
-%!error mustBeNonNan (NaN)
-%!error mustBeNonNan ([1 2 3 NaN])
+%!error <Invalid call> mustBeNonNan ()
+%!error <must be non-NaN> mustBeNonNan (NaN)
+%!error <input must be non-NaN> mustBeNonNan ([1 2 3 NaN])
--- a/scripts/miscellaneous/mustBeNonempty.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeNonempty.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,30 +26,38 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeNonempty (@var{x})
 ##
-## Requires that input @var{x} is nonempty.
+## Require that input @var{x} is nonempty.
 ##
-## Raises an error if the input @var{x} is not empty, as determined by
-## @code{! isempty (@var{x})}.
+## Raise an error if the input @var{x} is empty, as determined by
+## @code{isempty (@var{x})}.
 ##
+## @seealso{mustBeMember, mustBeNonzero, isempty}
 ## @end deftypefn
 
 function mustBeNonempty (x)
-  if isempty (x)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  if (isempty (x))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    error ("%s must be nonempty; got an empty", label);
+    error ("%s must not be empty", label);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeNonempty (42)
-%! mustBeNonempty ('Hello')
-%! mustBeNonempty (Inf)
-%! mustBeNonempty (NaN)
+%! mustBeNonempty (42);
+%! mustBeNonempty ("Hello");
+%! mustBeNonempty (Inf);
+%! mustBeNonempty (NaN);
 
-%!error mustBeNonempty ()
-%!error mustBeNonempty ([])
-%!error mustBeNonempty ('')
-%!error mustBeNonempty (reshape([], [0 3 3 3]))
+%!error <Invalid call> mustBeNonempty ()
+%!error <input must not be empty> mustBeNonempty ([])
+%!error <input must not be empty> mustBeNonempty ('')
+%!error <input must not be empty> mustBeNonempty (reshape ([], [0 3 3 3]))
--- a/scripts/miscellaneous/mustBeNonnegative.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeNonnegative.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,46 +26,51 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeNonnegative (@var{x})
 ##
-## Requires that input @var{x} is not negative.
+## Require that input @var{x} is not negative.
 ##
-## Raises an error if any element of the input @var{x} is negative, as
+## Raise an error if any element of the input @var{x} is negative, as
 ## determined by @code{@var{x} >= 0}.
 ##
+## @seealso{mustBeNonzero, mustBePositive}
 ## @end deftypefn
 
 function mustBeNonnegative (x)
-  tf = x >= 0;
-  tf = tf(:);
-  if ! all (tf)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  tf = (x(:) >= 0);
+  if (! all (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
+    bad_idx = find (! tf);
     try
-      bad = x(ix_bad);
-      errmsg = sprintf ( ...
-        "%s must be non-negative; got %d elements that were not: values %s", ...
-        label, numel (ix_bad), mat2str (bad));
-    catch err
-      errmsg = sprintf ( ...
-        "%s must be non-negative; got %d elements that were not: indexes %s", ...
-        label, numel (ix_bad), mat2str (ix_bad));
+      bad_val = x(bad_idx);
+      errmsg = sprintf ("%s must be non-negative; found %d elements that were not: values %s", ...
+                        label, numel (bad_idx), mat2str (bad_val));
+    catch
+      errmsg = sprintf ("%s must be non-negative; found %d elements that were not: indexes %s", ...
+                        label, numel (bad_idx), mat2str (bad_idx));
     end_try_catch
     error (errmsg);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeNonnegative (0)
-%! mustBeNonnegative (1)
-%! mustBeNonnegative (123.456)
-%! mustBeNonnegative (Inf)
-%! mustBeNonnegative (0:10)
-%! mustBeNonnegative (eps)
+%! mustBeNonnegative (0);
+%! mustBeNonnegative (1);
+%! mustBeNonnegative (123.456);
+%! mustBeNonnegative (Inf);
+%! mustBeNonnegative (0:10);
+%! mustBeNonnegative (eps);
 
-%!error mustBeNonnegative ()
-%!error mustBeNonnegative (-1)
-%!error mustBeNonnegative ([0 1 2 3 -4])
-%!error mustBeNonnegative (-Inf)
-%!error mustBeNonnegative (NaN)
+%!error <Invalid call> mustBeNonnegative ()
+%!error <input must be non-negative> mustBeNonnegative (-1)
+%!error <found 1 elements> mustBeNonnegative ([0 1 2 3 -4])
+%!error <input must be non-negative> mustBeNonnegative (-Inf)
+%!error <must be non-negative> mustBeNonnegative (NaN)
--- a/scripts/miscellaneous/mustBeNonpositive.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeNonpositive.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,43 +26,48 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeNonpositive (@var{x})
 ##
-## Requires that input @var{x} is not positive.
+## Require that input @var{x} is not positive.
 ##
-## Raises an error if any element of the input @var{x} is positive, as
+## Raise an error if any element of the input @var{x} is positive, as
 ## determined by @code{@var{x} <= 0}.
 ##
+## @seealso{mustBeNegative, mustBeNonzero}
 ## @end deftypefn
 
 function mustBeNonpositive (x)
-  tf = x <= 0;
-  tf = tf(:);
-  if ! all (tf)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  tf = (x(:) <= 0);
+  if (! all (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
+    bad_idx = find (! tf);
     try
-      bad = x(ix_bad);
-      errmsg = sprintf ( ...
-        "%s must be non-positive; got %d elements that were not: values %s", ...
-        label, numel (ix_bad), mat2str (bad));
-    catch err
-      errmsg = sprintf ( ...
-        "%s must be non-positive; got %d elements that were not: indexes %s", ...
-        label, numel (ix_bad), mat2str (ix_bad));
+      bad_val = x(bad_idx);
+      errmsg = sprintf ("%s must be non-positive; found %d elements that were not: values %s", ...
+                        label, numel (bad_idx), mat2str (bad_val));
+    catch
+      errmsg = sprintf ("%s must be non-positive; found %d elements that were not: indexes %s", ...
+                        label, numel (bad_idx), mat2str (bad_idx));
     end_try_catch
     error (errmsg);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeNonpositive (0)
-%! mustBeNonpositive (-1)
-%! mustBeNonpositive (-5:-1)
-%! mustBeNonpositive (-Inf)
+%! mustBeNonpositive (0);
+%! mustBeNonpositive (-1);
+%! mustBeNonpositive (-5:-1);
+%! mustBeNonpositive (-Inf);
 
-%!error mustBeNonpositive ()
-%!error mustBeNonpositive (NaN)
-%!error mustBeNonpositive (1)
-%!error mustBeNonpositive (-10:1)
+%!error <Invalid call> mustBeNonpositive ()
+%!error <must be non-positive> mustBeNonpositive (1)
+%!error <found 2 elements> mustBeNonpositive (-10:2)
+%!error <must be non-positive> mustBeNonpositive (NaN)
--- a/scripts/miscellaneous/mustBeNonsparse.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeNonsparse.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,28 +26,36 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeNonsparse (@var{x})
 ##
-## Requires that input @var{x} is not sparse.
+## Require that input @var{x} is not sparse.
 ##
-## Raises an error if the input @var{x} is sparse, as determined by
+## Raise an error if the input @var{x} is sparse, as determined by
 ## @code{issparse (@var{x})}.
 ##
+## @seealso{issparse}
 ## @end deftypefn
 
 function mustBeNonsparse (x)
-  if issparse (x)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  if (issparse (x))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    error ("%s must be nonsparse; got a sparse array", label);
+    error ("%s must be nonsparse", label);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeNonsparse ([])
-%! mustBeNonsparse (42)
-%! mustBeNonsparse (1:100)
-%! mustBeNonsparse (Inf)
+%! mustBeNonsparse ([]);
+%! mustBeNonsparse (42);
+%! mustBeNonsparse (1:100);
+%! mustBeNonsparse ("Hello World");
 
-%!error mustBeNonsparse (sparse(42))
-%!error mustBeNonsparse ()
+%!error <Invalid call> mustBeNonsparse ()
+%!error <input must be nonsparse> mustBeNonsparse (sparse (42))
--- a/scripts/miscellaneous/mustBeNonzero.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeNonzero.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,42 +26,44 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeNonzero (@var{x})
 ##
-## Requires that input @var{x} is not zero.
+## Require that input @var{x} is not zero.
 ##
-## Raises an error if any element of the input @var{x} is zero, as determined
-## by @code{@var{x} != 0}.
+## Raise an error if any element of the input @var{x} is zero, as determined
+## by @code{@var{x} == 0}.
 ##
+## @seealso{mustBeNonnegative, mustBePositive}
 ## @end deftypefn
 
-# TODO: Should NaN be considered nonzero? It fits the formal definition above,
-# but that may not be the spirit of the test. And it's not equal to any non-zero
-# value.
+function mustBeNonzero (x)
 
-function mustBeNonzero (x)
-  tf = x != 0;
-  tf = tf(:);
-  if ! all (tf)
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  tf = (x(:) == 0);
+  if (any (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
-    errmsg = sprintf ( ...
-      "%s must be non-zero; got %d elements that were zero: indexes %s", ...
-      label, numel (ix_bad), mat2str (ix_bad));
+    bad_idx = find (tf);
+    errmsg = sprintf ("%s must be non-zero; found %d elements that were zero: indexes %s", ...
+                      label, numel (bad_idx), mat2str (bad_idx));
     error (errmsg);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeNonzero (1)
-%! mustBeNonzero (-1)
-%! mustBeNonzero ([-5:-1 1:5])
-%! mustBeNonzero (Inf)
-%! mustBeNonzero (-Inf)
-%! mustBeNonzero (NaN)
-%! mustBeNonzero (eps)
+%! mustBeNonzero (1);
+%! mustBeNonzero (-1);
+%! mustBeNonzero ([-5:-1 1:5]);
+%! mustBeNonzero (Inf);
+%! mustBeNonzero (-Inf);
+%! mustBeNonzero (NaN);
+%! mustBeNonzero (eps);
 
-%!error mustBeNonzero ()
-%!error mustBeNonzero (0)
-%!error mustBeNonzero (-10:10)
+%!error <Invalid call> mustBeNonzero ()
+%!error <found 1 elements> mustBeNonzero (-10:10)
+%!error <found 2 elements> mustBeNonzero ([-1, 0, 0, 1])
--- a/scripts/miscellaneous/mustBeNumeric.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeNumeric.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,31 +26,39 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeNumeric (@var{x})
 ##
-## Requires that input @var{x} is numeric.
+## Require that input @var{x} is numeric.
 ##
-## Raises an error if the input @var{x} is not numeric, as determined by
+## Raise an error if the input @var{x} is not numeric, as determined by
 ## @code{isnumeric (@var{x})}.
 ##
+## @seealso{mustBeNumericOrLogical, isnumeric}
 ## @end deftypefn
 
 function mustBeNumeric (x)
-  if ! isnumeric (x)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  if (! isnumeric (x))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    error ("%s must be numeric; got a %s", label, class (x));
+    error ("%s must be numeric; found a %s", label, class (x));
   endif
+
 endfunction
 
+
 %!test
-%! mustBeNumeric ([])
-%! mustBeNumeric (42)
-%! mustBeNumeric (int32(42))
-%! mustBeNumeric (NaN)
+%! mustBeNumeric ([]);
+%! mustBeNumeric (42);
+%! mustBeNumeric (int32 (42));
+%! mustBeNumeric (NaN);
 
-%!error mustBeNumeric ()
-%!error mustBeNumeric ('foo')
-%!error mustBeNumeric (struct)
-%!error mustBeNumeric ({})
-%!error mustBeNumeric (true)
+%!error <Invalid call> mustBeNumeric ()
+%!error <found a char> mustBeNumeric ("foo")
+%!error <found a logical> mustBeNumeric (true)
+%!error <found a struct> mustBeNumeric (struct ())
+%!error <found a cell> mustBeNumeric (cell ())
--- a/scripts/miscellaneous/mustBeNumericOrLogical.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeNumericOrLogical.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,31 +26,39 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeNumericOrLogical (@var{x})
 ##
-## Requires that input @var{x} is numeric or logical.
+## Require that input @var{x} is numeric or logical.
 ##
-## Raises an error if the input @var{x} is not numeric or logical, as
+## Raise an error if the input @var{x} is not numeric or logical, as
 ## determined by @code{isnumeric (@var{x}) || islogical (@var{x})}.
 ##
+## @seealso{mustBeNumeric, isnumeric, islogical}
 ## @end deftypefn
 
 function mustBeNumericOrLogical (x)
-  if ! (isnumeric (x) || islogical (x))
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  if (! (isnumeric (x) || islogical (x)))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    error ("%s must be numeric or logical; got a %s", label, class (x));
+    error ("%s must be numeric or logical; found a %s", label, class (x));
   endif
+
 endfunction
 
+
 %!test
-%! mustBeNumericOrLogical ([])
-%! mustBeNumericOrLogical (true)
-%! mustBeNumericOrLogical (false)
-%! mustBeNumericOrLogical (42)
-%! mustBeNumericOrLogical (int32(42))
+%! mustBeNumericOrLogical ([]);
+%! mustBeNumericOrLogical (true);
+%! mustBeNumericOrLogical (false);
+%! mustBeNumericOrLogical (42);
+%! mustBeNumericOrLogical (int32 (42));
 
-%!error mustBeNumericOrLogical ()
-%!error mustBeNumericOrLogical ('foo')
-%!error mustBeNumericOrLogical ({})
-%!error mustBeNumericOrLogical (struct)
+%!error <Invalid call> mustBeNumericOrLogical ()
+%!error <found a char> mustBeNumericOrLogical ("foo")
+%!error <found a struct> mustBeNumericOrLogical (struct ())
+%!error <found a cell> mustBeNumericOrLogical (cell ())
--- a/scripts/miscellaneous/mustBePositive.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBePositive.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,46 +26,51 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBePositive (@var{x})
 ##
-## Requires that input @var{x} is positive.
+## Require that input @var{x} is positive.
 ##
-## Raises an error if any element of the input @var{x} is not positive, as
+## Raise an error if any element of the input @var{x} is not positive, as
 ## determined by @code{@var{x} > 0}.
 ##
+## @seealso{mustBeNonnegative, mustBeNonzero}
 ## @end deftypefn
 
 function mustBePositive (x)
-  tf = x > 0;
-  tf = tf(:);
-  if ! all (tf)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  tf = (x(:) > 0);
+  if (! all (tf))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    ix_bad = find (! tf);
+    bad_idx = find (! tf);
     try
-      bad = x(ix_bad);
-      errmsg = sprintf ( ...
-        "%s must be positive; got %d elements that were not: values %s", ...
-        label, numel (ix_bad), mat2str (bad));
-    catch err
-      errmsg = sprintf ( ...
-        "%s must be positive; got %d elements that were not: indexes %s", ...
-        label, numel (ix_bad), mat2str (ix_bad));
+      bad_val = x(bad_idx);
+      errmsg = sprintf ("%s must be positive; found %d elements that were not: values %s", ...
+                        label, numel (bad_idx), mat2str (bad_val));
+    catch
+      errmsg = sprintf ("%s must be positive; found %d elements that were not: indexes %s", ...
+                        label, numel (bad_idx), mat2str (bad_idx));
     end_try_catch
     error (errmsg);
   endif
+
 endfunction
 
+
 %!test
-%! mustBePositive (1)
-%! mustBePositive (123.456)
-%! mustBePositive (Inf)
-%! mustBePositive (eps)
+%! mustBePositive (1);
+%! mustBePositive (123.456);
+%! mustBePositive (Inf);
+%! mustBePositive (eps);
 
-%!error mustBePositive ()
-%!error mustBePositive (0)
-%!error mustBePositive (0:10)
-%!error mustBePositive (-1)
-%!error mustBePositive ([0 1 2 3 -4])
-%!error mustBePositive (-Inf)
-%!error mustBePositive (NaN)
+%!error <Invalid call> mustBePositive ()
+%!error <found 1 elements> mustBePositive (0)
+%!error <found 1 elements> mustBePositive (0:10)
+%!error <found 2 elements> mustBePositive ([-1 -2])
+%!error <found 2 elements> mustBePositive ([0 1 2 3 -4])
+%!error <found 1 elements> mustBePositive (-Inf)
+%!error <found 1 elements> mustBePositive (NaN)
--- a/scripts/miscellaneous/mustBeReal.m	Fri Sep 11 18:57:59 2020 -0400
+++ b/scripts/miscellaneous/mustBeReal.m	Fri Sep 11 20:04:07 2020 -0700
@@ -26,31 +26,39 @@
 ## -*- texinfo -*-
 ## @deftypefn {} {} mustBeReal (@var{x})
 ##
-## Requires that input @var{x} is real.
+## Require that input @var{x} is real.
 ##
-## Raises an error if the input @var{x} is not real, as determined by
+## Raise an error if the input @var{x} is not real, as determined by
 ## @code{isreal (@var{x})}.
 ##
+## @seealso{mustBeFinite, mustBeNonNan, isreal}
 ## @end deftypefn
 
 function mustBeReal (x)
-  if ! isreal (x)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  if (! isreal (x))
     label = inputname (1);
-    if isempty (label)
+    if (isempty (label))
       label = "input";
     endif
-    error ("%s must be real; got a complex value", label);
+    error ("%s must be real", label);
   endif
+
 endfunction
 
+
 %!test
-%! mustBeReal ([])
-%! mustBeReal (42)
-%! mustBeReal (Inf)
-%! mustBeReal (NaN)
-%! mustBeReal (1:100)
-%! mustBeReal (int32(42))
+%! mustBeReal ([]);
+%! mustBeReal (42);
+%! mustBeReal (Inf);
+%! mustBeReal (NaN);
+%! mustBeReal (1:100);
+%! mustBeReal (int32 (42));
 
-%!error mustBeReal ()
-%!error mustBeReal (i)
-%!error mustBeReal (2 + i)
+%!error <Invalid call> mustBeReal ()
+%!error <must be real> mustBeReal (i)
+%!error <input must be real> mustBeReal (2 + i)