changeset 33152:4035a1f71e07 bytecode-interpreter

maint: merge default to bytecode-interpreter.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Wed, 06 Mar 2024 11:34:10 -0500
parents 980bd18d962c (current diff) 365751dd06c1 (diff)
children 899647fde914
files
diffstat 6 files changed, 126 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/genpropdoc.m	Mon Mar 04 15:34:19 2024 -0500
+++ b/doc/interpreter/genpropdoc.m	Wed Mar 06 11:34:10 2024 -0500
@@ -87,7 +87,7 @@
   ##   "__fcnmsg__"  : replaced by a message explaining where to find
   ##                   documentation on the form of a callback function.
   ##   You may also cross reference properties using the label format
-  ##   OBJNAMEPROPERTY, e.g, "@xref{XREFaxescolor, , axes color property}."
+  ##   OBJNAMEPROPERTY, e.g., "@xref{XREFaxescolor, , axes color property}."
   ##
   ## -"valid": string that describes valid values for the current property.
   ##   Use "packopt" function to join options with " | " separator
@@ -1469,7 +1469,7 @@
         s.category = "Text Appearance";
 
       case "zlim"
-        s.doc = "Two-element vector @code{[zmin zmaz]} specifying the limits \
+        s.doc = "Two-element vector @code{[zmin zmax]} specifying the limits \
 for the z-axis.  __modemsg__.  @xref{XREFzlim, , @w{zlim function}}.";
         s.valid = valid_2elvec;
         s.category = "Axes Box Appearance";
@@ -2317,10 +2317,10 @@
 
       case "faces"
         s.doc = "__objname__ faces connectivity list stored as an M x N \
-matrix, with each of the M faces defined by a row of up to N  vectices, \
+matrix, with each of the M faces defined by a row of up to N vertices, \
 and each element contains the row index of a vertex stored in the \
 @ref{XREFpatchvertices, , @w{vertices property}}.  Faces with fewer than N \
-vertices use NaN values to fill empty row elemnets.";
+vertices use NaN values to fill empty row elements.";
         s.valid = valid_vecmat;
         s.category = "Coordinate Data";
 
@@ -2745,7 +2745,7 @@
         s.category = "Appearance";
 
       case "borderwidth"
-        s.doc = "The width of the the line border in pixels.";
+        s.doc = "The width of the line border in pixels.";
         s.valid = "whole number scalar";
         s.category = "Appearance";
 
@@ -2838,7 +2838,7 @@
         s.category = "Appearance";
 
       case "borderwidth"
-        s.doc = "The width of the the line border in pixels.";
+        s.doc = "The width of the line border in pixels.";
         s.valid = "whole number scalar";
         s.category = "Appearance";
 
@@ -3014,10 +3014,11 @@
 dependent on the control type. For @qcode{\"checkbox\"}, \
 @qcode{\"togglebutton\"}, and @qcode{\"radiobutton\"} controls, the \
 @qcode{\"max\"} value is assigned to the @qcode{\"value\"} property when the \
-control object is selected  For @qcode{\"slider\"} controls, @qcode{\"max\"} \
-defines the maximum value of the slider.  For @qcode{\"edit\"} and \
-@qcode{\"listbox\"} controls, if @code{Max - Min > 1}, then the control will \
-permit multiple line entries or list item selections, respectively.";
+control object is selected.  For @qcode{\"slider\"} controls, \
+@qcode{\"max\"} defines the maximum value of the slider.  For \
+@qcode{\"edit\"} and @qcode{\"listbox\"} controls, if @code{Max - Min > 1}, \
+then the control will permit multiple line entries or list item selections, \
+respectively.";
         s.valid = "scalar";
         s.category = "Control Options";
 
@@ -3026,7 +3027,7 @@
 dependent on the control type. For @qcode{\"checkbox\"}, \
 @qcode{\"togglebutton\"}, and @qcode{\"radiobutton\"} controls, the \
 @qcode{\"min\"} value is assigned to the @qcode{\"value\"} property when the \
-control object is not selected  For @qcode{\"slider\"} controls, \
+control object is not selected.  For @qcode{\"slider\"} controls, \
 @qcode{\"min\"} defines the minimum value of the slider.  For \
 @qcode{\"edit\"} and @qcode{\"listbox\"} controls, if @code{Max - Min > 1}, \
 then the control will permit multiple line entries or list item selections, \
@@ -3135,7 +3136,7 @@
 
       case "columnwidth"
         s.doc = "Setting for determining width of each column, valid \
-options including:  @qcode{\"auto\"}, @qcode{\"fit\"}, evenly divided \
+options include:  @qcode{\"auto\"}, @qcode{\"fit\"}, evenly divided \
 multiples specified as @qcode{\"1x\"}, @qcode{\"2x\"}, etc., or a 1 x N cell \
 vector where each element corresponds to one of N table columns, and \
 containing any of the above options or a fixed width specified in pixels.";
--- a/libinterp/corefcn/fft2.cc	Mon Mar 04 15:34:19 2024 -0500
+++ b/libinterp/corefcn/fft2.cc	Wed Mar 06 11:34:10 2024 -0500
@@ -56,11 +56,11 @@
     {
       double dval = args(1).double_value ();
       if (math::isnan (dval))
-        error ("%s: number of rows (N) cannot be NaN", fcn);
+        error ("%s: number of rows (M) cannot be NaN", fcn);
 
       n_rows = math::nint_big (dval);
       if (n_rows < 0)
-        error ("%s: number of rows (N) must be greater than zero", fcn);
+        error ("%s: number of rows (M) must be greater than zero", fcn);
     }
 
   octave_idx_type n_cols = -1;
@@ -68,11 +68,11 @@
     {
       double dval = args(2).double_value ();
       if (math::isnan (dval))
-        error ("%s: number of columns (M) cannot be NaN", fcn);
+        error ("%s: number of columns (N) cannot be NaN", fcn);
 
       n_cols = math::nint_big (dval);
       if (n_cols < 0)
-        error ("%s: number of columns (M) must be greater than zero", fcn);
+        error ("%s: number of columns (N) must be greater than zero", fcn);
     }
 
   for (int i = 0; i < dims.ndims (); i++)
@@ -89,12 +89,12 @@
   else
     dims(1) = n_cols;
 
-  if (dims.all_zero () || n_rows == 0 || n_cols == 0)
+  if (dims.any_zero ())
     {
       if (arg.is_single_type ())
-        return octave_value (FloatMatrix ());
+        return octave_value (FloatNDArray (dims));
       else
-        return octave_value (Matrix ());
+        return octave_value (NDArray (dims));
     }
 
   if (arg.is_single_type ())
@@ -156,6 +156,20 @@
   return do_fft2 (args, "fft2", 0);
 }
 
+/*
+%!testif HAVE_FFTW <*65414>
+%! sz = size (fft2 (ones (2, 0, 3)));
+%! assert (sz, [2, 0, 3]);
+
+%!testif HAVE_FFTW <*65414>
+%! sz = size (fft2 (ones (5, 4, 3), 2, 0));
+%! assert (sz, [2, 0, 3]);
+
+%!error <number of rows \(M\) cannot be NaN> fft2 (ones (5,4,3), NaN, 2) 
+%!error <number of rows \(M\) .* greater than zero> fft2 (ones (5,4,3), -1, 2) 
+%!error <number of columns \(N\) cannot be NaN> fft2 (ones (5,4,3), 2, NaN) 
+%!error <number of columns \(N\) .* greater than zero> fft2 (ones (5,4,3), 2, -1) 
+*/
 
 DEFUN (ifft2, args, ,
        doc: /* -*- texinfo -*-
@@ -177,6 +191,14 @@
 }
 
 /*
+%!testif HAVE_FFTW <*65414>
+%! sz = size (ifft2 (ones (2, 0, 3)));
+%! assert (sz, [2, 0, 3]);
+
+%!testif HAVE_FFTW <*65414>
+%! sz = size (ifft2 (ones (5, 4, 3), 2, 0));
+%! assert (sz, [2, 0, 3]);
+
 ## Author: David Billinghurst (David.Billinghurst@riotinto.com.au)
 ##         Comalco Research and Technology
 ##         02 May 2000
@@ -258,6 +280,11 @@
 %! s = ifft2 (S);
 %!
 %! assert (s, answer, 30* eps ("single"));
+
+%!error <number of rows \(M\) cannot be NaN> ifft2 (ones (5,4,3), NaN, 2) 
+%!error <number of rows \(M\) .* greater than zero> ifft2 (ones (5,4,3), -1, 2) 
+%!error <number of columns \(N\) cannot be NaN> ifft2 (ones (5,4,3), 2, NaN) 
+%!error <number of columns \(N\) .* greater than zero> ifft2 (ones (5,4,3), 2, -1) 
 */
 
 OCTAVE_END_NAMESPACE(octave)
--- a/libinterp/corefcn/fftn.cc	Mon Mar 04 15:34:19 2024 -0500
+++ b/libinterp/corefcn/fftn.cc	Wed Mar 06 11:34:10 2024 -0500
@@ -76,12 +76,12 @@
         }
     }
 
-  if (dims.all_zero ())
+  if (dims.any_zero ())
     {
       if (arg.is_single_type ())
-        return octave_value (FloatMatrix ());
+        return octave_value (FloatNDArray (dims));
       else
-        return octave_value (Matrix ());
+        return octave_value (NDArray (dims));
     }
 
   if (arg.is_single_type ())
@@ -143,6 +143,16 @@
   return do_fftn (args, "fftn", 0);
 }
 
+/*
+%!testif HAVE_FFTW <*65414>
+%! sz = size (fftn (ones (2, 0, 3)));
+%! assert (sz, [2, 0, 3]);
+
+%!testif HAVE_FFTW <*65414>
+%! sz = size (fftn (ones (5, 4, 3), [2, 0, 3]));
+%! assert (sz, [2, 0, 3]);
+*/
+
 DEFUN (ifftn, args, ,
        doc: /* -*- texinfo -*-
 @deftypefn  {} {@var{A} =} ifftn (@var{B})
@@ -162,4 +172,14 @@
   return do_fftn (args, "ifftn", 1);
 }
 
+/*
+%!testif HAVE_FFTW <*65414>
+%! sz = size (ifftn (ones (2, 0, 3)));
+%! assert (sz, [2, 0, 3]);
+
+%!testif HAVE_FFTW <*65414>
+%! sz = size (ifftn (ones (5, 4, 3), [2, 0, 3]));
+%! assert (sz, [2, 0, 3]);
+*/
+
 OCTAVE_END_NAMESPACE(octave)
--- a/scripts/miscellaneous/methods.m	Mon Mar 04 15:34:19 2024 -0500
+++ b/scripts/miscellaneous/methods.m	Wed Mar 06 11:34:10 2024 -0500
@@ -60,14 +60,19 @@
   endif
 
   if (isobject (obj))
-    ## Call internal C++ function for Octave objects
+    ## Call internal C++ function for Octave objects.
     mtds_list = __methods__ (obj);
   elseif (ischar (obj))
-    ## Could be a classname for an Octave class or Java class.
+    ## CLASSNAME could be an Octave class or Java class.
     ## Try Octave class first.
     [mtds_list, valid] = __methods__ (obj);
     if (! valid)
-      mtds_str = javaMethod ("getMethods", "org.octave.ClassHelper", obj);
+      ## Try Java class second.
+      try
+        mtds_str = javaMethod ("getMethods", "org.octave.ClassHelper", obj);
+      catch
+        error ("methods: class '%s' not found", obj);
+      end_try_catch
       mtds_list = ostrsplit (mtds_str, ';');
       mtds_list = mtds_list(:);  # return a column vector for compatibility
       havesigs = true;
@@ -158,4 +163,5 @@
 ## Test input validation
 %!error <Invalid call> methods ()
 %!error <invalid option> methods ("ftp", "option1")
+%!error <class 'foobar' not found> methods ('foobar')
 %!error <invalid input argument> methods (1)
--- a/scripts/statistics/mad.m	Mon Mar 04 15:34:19 2024 -0500
+++ b/scripts/statistics/mad.m	Wed Mar 06 11:34:10 2024 -0500
@@ -184,6 +184,32 @@
 %!assert (mad (ones (2, 0, 1, 0)), ones (1, 0, 1, 0))
 
 ## Test Inf handling
+%!assert (mad ([3, 4, Inf]), Inf)
+%!assert (mad ([Inf, 3, 4]), Inf)
+%!assert (mad ([3, 4, Inf], 0), Inf)
+%!assert (mad ([3, 4, Inf], 0, 1), [0, 0, NaN])
+%!assert (mad ([3, 4, Inf], 0, 2), Inf)
+%!assert (mad ([3, 4, Inf], 0, 3), [0, 0, NaN])
+%!assert (mad ([3, 4, Inf]', 0), Inf)
+%!assert (mad ([3, 4, Inf]', 0, 1), Inf)
+%!assert (mad ([3, 4, Inf]', 0, 2), [0; 0; NaN])
+%!assert (mad ([3, 4, Inf]', 0, 3), [0; 0; NaN])
+
+%!assert (mad ([Inf, 3, 4], 1), 1)
+%!assert (mad ([3, 4, Inf], 1), 1)
+%!assert (mad ([3, 4, Inf], 1, 1), [0, 0, NaN])
+%!assert (mad ([3, 4, Inf], 1, 2), 1)
+%!assert (mad ([3, 4, Inf], 1, 3), [0, 0, NaN])
+%!assert (mad ([3, 4, Inf]', 1), 1)
+%!assert (mad ([3, 4, Inf]', 1, 1), 1)
+%!assert (mad ([3, 4, Inf]', 1, 2), [0; 0; NaN])
+%!assert (mad ([3, 4, Inf]', 1, 3), [0; 0; NaN])
+
+%!assert (mad ([3, Inf, Inf], 1), Inf)
+%!assert (mad ([3, 4, 5, Inf], 1), 1)
+%!assert (mad ([3, 4, Inf, Inf], 1), Inf)
+%!assert (mad ([3, Inf, Inf, Inf], 1), Inf)
+
 %!assert <*65405> (mad ([-Inf, Inf]), NaN)
 %!assert <*65405> (mad ([-Inf, Inf], 0), NaN)
 %!assert <*65405> (mad ([-Inf, Inf], 1), NaN)
--- a/scripts/statistics/median.m	Mon Mar 04 15:34:19 2024 -0500
+++ b/scripts/statistics/median.m	Wed Mar 06 11:34:10 2024 -0500
@@ -382,7 +382,10 @@
         m = x(k);
         if (! mod (n, 2))
           ## Even
-          if (any (isa (x, "integer")))
+          if (any (isinf ([x(k), x(k+1)])))
+            ## If either center value is Inf, replace m by +/-Inf or NaN.
+            m = x(k) + x(k+1);
+          elseif (any (isa (x, "integer")))
             ## avoid int overflow issues
             m2 = x(k + 1);
             if (sign (m) != sign (m2))
@@ -625,8 +628,24 @@
 %!assert (median ([Inf, 3, 4]), 4)
 %!assert (median ([Inf, 3, Inf]), Inf)
 
+%!assert (median ([1, 2, Inf]), 2)
+%!assert (median ([1, 2, Inf, Inf]), Inf)
+%!assert (median ([1, -Inf, Inf, Inf]), Inf)
+%!assert (median ([-Inf, -Inf, Inf, Inf]), NaN)
+%!assert (median([-Inf, Inf, Inf, Inf]), Inf)
+%!assert (median([-Inf, -Inf, -Inf, Inf]), -Inf)
+%!assert (median([-Inf, -Inf, -Inf, 2]), -Inf)
+%!assert (median([-Inf, -Inf, 1, 2]), -Inf)
+
+%!assert (median ([Inf, Inf, NaN]), NaN)
+%!assert (median ([-Inf, Inf, NaN]), NaN)
+%!assert (median ([Inf, Inf, NaN], "omitnan"), Inf)
+%!assert (median ([-Inf, Inf, NaN], "omitnan"), NaN)
+%!assert (median ([-Inf, Inf, 3, NaN], "omitnan"), 3)
+%!assert (median ([-Inf, Inf, 3, -Inf, NaN], "omitnan"), -Inf)
+
 %!assert (median ([]), NaN)
-%!assert (median (ones (1, 0)), NaN) 
+%!assert (median (ones (1, 0)), NaN)
 %!assert (median (ones (0, 1)), NaN)
 %!assert (median ([], 1), NaN (1, 0))
 %!assert (median ([], 2), NaN (0, 1))