changeset 33229:3305b504bc2b bytecode-interpreter

maint: Merge default to bytecode-interpreter.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 20 Mar 2024 08:13:12 +0100
parents 5aa35bb9063c (current diff) d5c5484322d1 (diff)
children 5565b3e6eb60
files
diffstat 9 files changed, 101 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/etc/NEWS.10.md	Sun Mar 17 22:45:13 2024 -0400
+++ b/etc/NEWS.10.md	Wed Mar 20 08:13:12 2024 +0100
@@ -24,6 +24,10 @@
 
 - `jsonencode` now outputs integers and floating point integers without ".0"
   suffix.
+  
+- `hist` now accepts N-dimensional array inputs for input `Y` which is
+  processed in columns as if the array was flattened to a 2-dimensional
+  array.
 
 ### Graphical User Interface
 
--- a/libgui/src/files-dock-widget.cc	Sun Mar 17 22:45:13 2024 -0400
+++ b/libgui/src/files-dock-widget.cc	Wed Mar 20 08:13:12 2024 +0100
@@ -406,10 +406,6 @@
      // FIXME: use value<Qt::SortOrder> instead of static cast after
      //        dropping support of Qt 5.4
 
-  if (settings.contains (fb_column_state.settings_key ()))
-    m_file_tree_view->header ()->restoreState
-      (settings.value (fb_column_state.settings_key ()).toByteArray ());
-
   // Set header properties for sorting
   m_file_tree_view->header ()->setSectionsClickable (true);
   m_file_tree_view->header ()->setSectionsMovable (true);
@@ -468,6 +464,23 @@
 
   if (! p)
     make_window ();
+
+  // Initialize column order and width of the file browser. From this post,
+  // https://www.qtcentre.org/threads/26675-QTableView-saving-restoring-columns-widths
+  // this might fail if done directly in the constructor. This effect shows
+  // up in the GUI since Qt 6.6.x. As a solution, the following timer ensures
+  // that the header is restored when the event loop is idle.
+  QTimer::singleShot (0, this, SLOT(restore_header_state ()));
+}
+
+void
+files_dock_widget::restore_header_state ()
+{
+  gui_settings settings;
+
+  if (settings.contains (fb_column_state.settings_key ()))
+    m_file_tree_view->header ()->restoreState
+      (settings.value (fb_column_state.settings_key ()).toByteArray ());
 }
 
 void
--- a/libgui/src/files-dock-widget.h	Sun Mar 17 22:45:13 2024 -0400
+++ b/libgui/src/files-dock-widget.h	Wed Mar 20 08:13:12 2024 +0100
@@ -136,6 +136,7 @@
 
 private slots:
 
+  void restore_header_state ();
   void headercontextmenu_requested (const QPoint& pos);
   void toggle_header (int col);
 
--- a/libgui/src/workspace-view.cc	Sun Mar 17 22:45:13 2024 -0400
+++ b/libgui/src/workspace-view.cc	Wed Mar 20 08:13:12 2024 +0100
@@ -39,6 +39,7 @@
 #include <QMessageBox>
 #include <QPushButton>
 #include <QSignalMapper>
+#include <QTimer>
 #include <QVBoxLayout>
 
 #include "gui-preferences-ws.h"
@@ -107,9 +108,6 @@
 
   //enable sorting (setting column and order after model was set)
   m_view->setSortingEnabled (true);
-  // Initialize column order and width of the workspace
-  m_view->horizontalHeader ()->restoreState
-    (settings.value (ws_column_state.settings_key ()).toByteArray ());
 
   // Set header properties for sorting
   m_view->horizontalHeader ()->setSectionsClickable (true);
@@ -151,6 +149,23 @@
 
   if (! p)
     make_window ();
+
+  // Initialize column order and width of the workspace. From this post,
+  // https://www.qtcentre.org/threads/26675-QTableView-saving-restoring-columns-widths
+  // this might fail if done directly in the constructor. This effect shows
+  // up in the GUI since Qt 6.6.x. As a solution, the following timer ensures
+  // that the header is restored when the event loop is idle.
+  QTimer::singleShot (0, this, SLOT(restore_header_state ()));
+}
+
+void
+workspace_view::restore_header_state ()
+{
+  gui_settings settings;
+
+  if (settings.contains (ws_column_state.settings_key ()))
+    m_view->horizontalHeader ()->restoreState
+      (settings.value (ws_column_state.settings_key ()).toByteArray ());
 }
 
 void
--- a/libgui/src/workspace-view.h	Sun Mar 17 22:45:13 2024 -0400
+++ b/libgui/src/workspace-view.h	Wed Mar 20 08:13:12 2024 +0100
@@ -78,6 +78,7 @@
 
 protected slots:
 
+  void restore_header_state ();
   void filter_update (const QString& expression);
   void filter_activate (bool enable);
   void update_filter_history ();
--- a/m4/acinclude.m4	Sun Mar 17 22:45:13 2024 -0400
+++ b/m4/acinclude.m4	Wed Mar 20 08:13:12 2024 +0100
@@ -2287,17 +2287,17 @@
 dnl Check for library that exports SUNContext_Create.
 dnl
 AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SUNCONTEXT_CREATE], [
-  save_LIBS=$LIBS
+  ac_octave_save_LIBS=$LIBS
   LIBS="$SUNDIALS_IDA_LIBS $SUNDIALS_NVECSERIAL_LIBS $LIBS"
   dnl Check for SUNContext_Create without linking to libsundials_core.
   dnl That should succeed for SUNDIALS version 6.
   AC_CHECK_FUNC([SUNContext_Create])
-  LIBS="$save_LIBS"
+  LIBS="$ac_octave_save_LIBS"
   if test "x$ac_cv_func_SUNContext_Create" != xyes; then
     ## SUNDIALS version 7 exports SUNContext_Create from libsundials_core
-    save_CPPFLAGS="$CPPFLAGS"
-    save_LDFLAGS="$LDFLAGS"
-    save_LIBS="$LIBS"
+    ac_octave_save_CPPFLAGS="$CPPFLAGS"
+    ac_octave_save_LDFLAGS="$LDFLAGS"
+    ac_octave_save_LIBS="$LIBS"
     LIBS="$SUNDIALS_CORE_LIBS $LIBS"
     LDFLAGS="$SUNDIALS_CORE_LDFLAGS $LDFLAGS"
     CPPFLAGS="$SUNDIALS_CORE_CPPFLAGS $CPPFLAGS"
@@ -2306,9 +2306,9 @@
     OCTAVE_CHECK_LIB(sundials_core, [SUNDIALS core], [],
       [sundials_core.h sundials/sundials_core.h], [SUNContext_Create],
       [], [])
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
+    CPPFLAGS="$ac_octave_save_CPPFLAGS"
+    LDFLAGS="$ac_octave_save_LDFLAGS"
+    LIBS="$ac_octave_save_LIBS"
   fi
   if test "x$ac_cv_func_SUNContext_Create" = xyes \
     || test "x$octave_cv_lib_sundials_core" = xyes; then
@@ -2442,9 +2442,9 @@
   ## Check for library that exports SUNContext_Create
   OCTAVE_CHECK_SUNDIALS_SUNCONTEXT_CREATE
   ## Check for current KLU function name first.
-  save_CPPFLAGS="$CPPFLAGS"
-  save_LDFLAGS="$LDFLAGS"
-  save_LIBS="$LIBS"
+  ac_octave_save_CPPFLAGS="$CPPFLAGS"
+  ac_octave_save_LDFLAGS="$LDFLAGS"
+  ac_octave_save_LIBS="$LIBS"
   CPPFLAGS="$SUNDIALS_CORE_CPPFLAGS $CPPFLAGS"
   LDFLAGS="$SUNDIALS_CORE_LDFLAGS $LDFLAGS"
   LIBS="$SUNDIALS_CORE_LIBS $LIBS"
@@ -2532,9 +2532,9 @@
     warn_sundials_sunlinsol_klu="SUNDIALS IDA library not configured with SUNLINSOL_KLU or sunlinsol_klu.h is not usable.  The solvers ode15i and ode15s will not support the sparse Jacobian feature."
     OCTAVE_CONFIGURE_WARNING([warn_sundials_sunlinsol_klu])
   fi
-  CPPFLAGS="$save_CPPFLAGS"
-  LDFLAGS="$save_LDFLAGS"
-  LIBS="$save_LIBS"
+  CPPFLAGS="$ac_octave_save_CPPFLAGS"
+  LDFLAGS="$ac_octave_save_LDFLAGS"
+  LIBS="$ac_octave_save_LIBS"
 ])
 dnl
 dnl Like AC_CONFIG_FILES, but don't touch the output file if it already
--- a/scripts/gui/uifigure.m	Sun Mar 17 22:45:13 2024 -0400
+++ b/scripts/gui/uifigure.m	Wed Mar 20 08:13:12 2024 +0100
@@ -37,6 +37,9 @@
 ## @ref{Figure Properties}.  This function differs from @code{figure} in that
 ## the created figure is optimized for application development, rather than
 ## plotting.  This means features such as menubars and toolbars are turned off.
+## This is not perfect replacement for the @sc{matlab} uifigure object as the
+## properties @qcode{"AutoResizeChildren"}, @qcode{"Icon"}, and
+## @qcode{"Scrollable"} are not implemented.
 ## @seealso{uipanel, uibuttongroup}
 ## @end deftypefn
 
@@ -47,33 +50,43 @@
 
 function h = uifigure (varargin)
 
-  if (mod (nargin, 2) != 0)
+  if (rem (nargin, 2) != 0)
     error ("uifigure: PROPERTY/VALUE parameters must occur in pairs");
   endif
 
+  strfcn = @(s) any (strcmpi (s, {'AutoResizeChildren', 'Icon', 'Scrollable'}));
+  idx = cellfun (strfcn, varargin (1:2:end));
+  if (any (idx))
+    idx = repelem (idx, 2); 
+    props = varargin(idx);  # save special props for applying later
+    varargin(idx) = [];     # remove special props from varargin
+  endif
+
   h = __go_figure__ (NaN, "handlevisibility", "off",
                           "numbertitle", "off", "integerhandle", "off",
-                          "menubar", "none", "toolbar", "none");
+                          "menubar", "none", "toolbar", "none",
+                          varargin{:});
 
   ## Add uifigure-specific properties on top of regular figure graphics object
   ## FIXME: There is no implementation behind these properties.
   addproperty ("AutoResizeChildren", h, "boolean", "on");
+  addproperty ("Icon", h, "data", []);
   addproperty ("Scrollable", h, "boolean", "off");
 
-  ## Apply any overrides.
-  if (! isempty (varargin))
-    set (h, varargin{:});
+  ## Set values for special properties added above
+  if (! isempty (props))
+    set (h, props{:});
   endif
 
 endfunction
 
 
 %!test
-%! hf = uifigure ("visible", "off");
+%! hf = uifigure ("visible", "off", "Icon", magic (3));
 %! unwind_protect
 %!   assert (isfigure (hf));
-%!   assert (get (hf, {"numbertitle", "menubar", "scrollable"}),
-%!                    {"off", "none", "off"});
+%!   assert (get (hf, {"numbertitle", "menubar", "icon", "scrollable"}),
+%!                    {"off", "none", magic(3), "off"});
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
--- a/scripts/plot/draw/hist.m	Sun Mar 17 22:45:13 2024 -0400
+++ b/scripts/plot/draw/hist.m	Wed Mar 20 08:13:12 2024 +0100
@@ -84,8 +84,8 @@
 ## @var{nn} (numbers of elements) and @var{xx} (bin centers) such that
 ## @code{bar (@var{xx}, @var{nn})} will plot the histogram.  If @var{y} is a
 ## vector, @var{nn} and @var{xx} will be row vectors.  If @var{y} is an array,
-## @var{nn} will be an array with one column of element counts for each column
-## in @var{y}, and @var{xx} will be a column vector of bin centers.
+## @var{nn} will be a 2-D array with one column of element counts for each
+## column in @var{y}, and @var{xx} will be a column vector of bin centers.
 ##
 ## @seealso{histc, bar, pie, rose}
 ## @end deftypefn
@@ -193,6 +193,11 @@
     norm = norm (:).';  # Ensure vector orientation.
   endif
 
+  ## Flatten y from N-D to 2-D array
+  if (ndims (y) > 2)
+    y = y(:,:);
+  endif
+
   ## Perform histogram calculation
   cutoff = (x(1:end-1,:) + x(2:end,:)) / 2;
 
@@ -409,6 +414,21 @@
 %! [nn, xx] = hist (double (1:10), single ([1, 5, 10]));
 %! assert (isa (xx, "single"));
 
+## Test N-D arrays produce the same result as 2-D arrays
+%!test <*65478>  # Small n
+%! a = magic (4);
+%! b = permute (a, [1, 3, 2]);
+%! [na, xa] = hist (a);
+%! [nb, xb] = hist (b);
+%! assert ({na, xa}, {nb, xb});
+
+%!test <*65478>  # Large n
+%! a = magic (4);
+%! b = permute (a, [1, 3, 2]);
+%! [na, xa] = hist (a, 30);
+%! [nb, xb] = hist (b, 30);
+%! assert ({na, xa}, {nb, xb});
+
 ## Test input validation
 %!error <Invalid call> hist ()
 %!error <Y must be real-valued> hist (2+i)
--- a/scripts/plot/draw/patch.m	Sun Mar 17 22:45:13 2024 -0400
+++ b/scripts/plot/draw/patch.m	Wed Mar 20 08:13:12 2024 +0100
@@ -75,19 +75,14 @@
 ## @enumerate
 ## @item
 ## The full list of properties is documented at @ref{Patch Properties}.
-## Useful patch properties include: @qcode{"cdata"}, @qcode{"edgecolor"},
-## @qcode{"facecolor"}, @qcode{"faces"}, @qcode{"vertices"}, and
-## @qcode{"facevertexcdata"}.
-## @item
-## Properties specifying patch geometry (@qcode{"xdata"}, @qcode{"ydata"},
-## @qcode{"zdata"}, @qcode{"faces"}, @qcode{"vertices"}) should be specified
-## before other properties to avoid unexpected plot outputs or errors.
+## Useful patch properties include: @qcode{"edgecolor"}, @qcode{"facecolor"},
+## @qcode{"faces"}, @qcode{"vertices"}, and @qcode{"facevertexcdata"}.
 ## @item
 ## Unexpected geometry results can occur from mixing x-y-z and
 ## face-vertex forms of defining geometry.
 ## @item
 ## Unexpected patch color results can occur from using @qcode{"cdata"} color
-## definitons with face-vertex defined geometry or @qcode{"facecentercdata"}
+## definitons with face-vertex defined geometry or @qcode{"facevertexcdata"}
 ## color definitions with x-y-z defined geometry.
 ## @end enumerate
 ## @seealso{fill, get, set}