changeset 19117:a4c226a963c5

Deprecate finite in favor of isfinite. * NEWS: Announce change. * mappers.cc: Remove DEFALIAS of finite to isfinite. Replace finite with isfinite in %!tests. * scripts/deprecated/finite.m: New m-file script to replace C++ DEFALIAS. * scripts/deprecated/module.mk: Add finite.m to build system. * cosd.m, sind.m, tand.m, nthroot.m: Replace occurrences of finite with isfinite in core m-files.
author Rik <rik@octave.org>
date Sat, 20 Sep 2014 20:20:41 -0700
parents d657ed3f5f25
children 9c5a17d5fc19
files NEWS libinterp/corefcn/mappers.cc scripts/deprecated/finite.m scripts/deprecated/module.mk scripts/elfun/cosd.m scripts/elfun/sind.m scripts/elfun/tand.m scripts/specfun/nthroot.m
diffstat 8 files changed, 72 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Sat Sep 20 20:10:54 2014 -0700
+++ b/NEWS	Sat Sep 20 20:20:41 2014 -0700
@@ -94,9 +94,10 @@
       -------------------|------------------
       bicubic            | interp2
       find_dir_in_path   | dir_in_loadpath
+      finite             | isfinite
       nfields            | numfields
+      syl                | sylvester
       usage              | print_usage
-      syl                | sylvester
 
     The following functions were deprecated in Octave 3.8 and have been
     removed from Octave 4.2.
--- a/libinterp/corefcn/mappers.cc	Sat Sep 20 20:10:54 2014 -0700
+++ b/libinterp/corefcn/mappers.cc	Sat Sep 20 20:20:41 2014 -0700
@@ -895,15 +895,15 @@
 
 DEFUN (isfinite, args, ,
        "-*- texinfo -*-\n\
-@deftypefn  {Mapping Function} {} isfinite (@var{x})\n\
-@deftypefnx {Mapping Function} {} finite (@var{x})\n\
+@deftypefn {Mapping Function} {} isfinite (@var{x})\n\
 Return a logical array which is true where the elements of @var{x} are\n\
 finite values and false where they are not.\n\
+\n\
 For example:\n\
 \n\
 @example\n\
 @group\n\
-finite ([13, Inf, NA, NaN])\n\
+isfinite ([13, Inf, NA, NaN])\n\
      @result{} [ 1, 0, 0, 0 ]\n\
 @end group\n\
 @end example\n\
@@ -920,16 +920,16 @@
 }
 
 /*
-%!assert (!finite (Inf))
-%!assert (!finite (NaN))
-%!assert (finite (rand (1,10)))
+%!assert (!isfinite (Inf))
+%!assert (!isfinite (NaN))
+%!assert (isfinite (rand (1,10)))
 
-%!assert (!finite (single (Inf)))
-%!assert (!finite (single (NaN)))
-%!assert (finite (single (rand (1,10))))
+%!assert (!isfinite (single (Inf)))
+%!assert (!isfinite (single (NaN)))
+%!assert (isfinite (single (rand (1,10))))
 
-%!error finite ()
-%!error finite (1, 2)
+%!error isfinite ()
+%!error isfinite (1, 2)
 */
 
 DEFUN (fix, args, ,
@@ -2243,4 +2243,3 @@
 
 DEFALIAS (gammaln, lgamma);
 
-DEFALIAS (finite, isfinite);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/deprecated/finite.m	Sat Sep 20 20:20:41 2014 -0700
@@ -0,0 +1,52 @@
+## Copyright (C) 2014 John W. Eaton
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
+## -*- texinfo -*-
+## @deftypefn {Mapping Function} {} finite (@var{x})
+##
+## @code{finite} is deprecated and will be removed in Octave version 4.6.
+## Please use @code{isfinite} in all new code.
+##
+## Return a logical array which is true where the elements of @var{x} are
+## finite values and false where they are not.
+## For example:
+## 
+## @example
+## @group
+## finite ([13, Inf, NA, NaN])
+##      @result{} [ 1, 0, 0, 0 ]
+## @end group
+## @end example
+## @seealso{isfinite, isinf, isnan, isna}
+## @end deftypefn
+
+## Deprecated in version 4.2
+
+function retval = finite (varargin)
+
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "finite is obsolete and will be removed from a future version of Octave, please use isfinite instead");
+  endif
+
+  retval = isfinite (varargin{:});
+
+endfunction
+
--- a/scripts/deprecated/module.mk	Sat Sep 20 20:10:54 2014 -0700
+++ b/scripts/deprecated/module.mk	Sat Sep 20 20:20:41 2014 -0700
@@ -3,6 +3,7 @@
 deprecated_FCN_FILES = \
   deprecated/bicubic.m \
   deprecated/find_dir_in_path.m \
+  deprecated/finite.m \
   deprecated/isstr.m \
   deprecated/nfields.m \
   deprecated/strmatch.m \
--- a/scripts/elfun/cosd.m	Sat Sep 20 20:10:54 2014 -0700
+++ b/scripts/elfun/cosd.m	Sat Sep 20 20:20:41 2014 -0700
@@ -34,7 +34,7 @@
   I = x / 180;
   y = cos (I .* pi);
   I = I + 0.5;
-  y(I == fix (I) & finite (I)) = 0;
+  y(I == fix (I) & isfinite (I)) = 0;
 
 endfunction
 
--- a/scripts/elfun/sind.m	Sat Sep 20 20:10:54 2014 -0700
+++ b/scripts/elfun/sind.m	Sat Sep 20 20:20:41 2014 -0700
@@ -33,7 +33,7 @@
 
   I = x / 180;
   y = sin (I .* pi);
-  y(I == fix (I) & finite (I)) = 0;
+  y(I == fix (I) & isfinite (I)) = 0;
 
 endfunction
 
--- a/scripts/elfun/tand.m	Sat Sep 20 20:10:54 2014 -0700
+++ b/scripts/elfun/tand.m	Sat Sep 20 20:20:41 2014 -0700
@@ -35,8 +35,8 @@
   I0 = x / 180;
   I90 = (x-90) / 180;
   y = tan (I0 .* pi);
-  y(I0 == fix (I0) & finite (I0)) = 0;
-  y(I90 == fix (I90) & finite (I90)) = Inf;
+  y(I0 == fix (I0) & isfinite (I0)) = 0;
+  y(I90 == fix (I90) & isfinite (I90)) = Inf;
 
 endfunction
 
--- a/scripts/specfun/nthroot.m	Sat Sep 20 20:10:54 2014 -0700
+++ b/scripts/specfun/nthroot.m	Sat Sep 20 20:20:41 2014 -0700
@@ -73,10 +73,10 @@
       y = x .^ (1/n);
     endif
 
-    if (integer_n && n > 0 && finite (n))
+    if (integer_n && n > 0 && isfinite (n))
       ## FIXME: What is this correction for?
       y = ((n-1)*y + x ./ (y.^(n-1))) / n;
-      y = merge (finite (y), y, x);
+      y = merge (isfinite (y), y, x);
     endif
 
   endif