bugGNU Octave - Bugs: bug #64995, implement height and width as...


bug #64995: implement height and width as aliases for rows and columns for matlab compatibility

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Thu 07 Dec 2023 09:52:05 PM UTC
Category:  Octave Function Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  10.1.0 (current default)
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Tue 12 Dec 2023 06:00:53 AM UTC, comment #6: 

Verified fix.  Closing report.

Rik <rik5>
Group administrator
Tue 12 Dec 2023 04:58:01 AM UTC, comment #5: 

I pushed docstring updates for isbool, ifelse, dbnext, exit, and home aliases to stable as

didn't add notes for the Inf/NaN/I,J,j aliases that are just case differences (and the i I j J ones are specifically noted in the doc). Also opted not to add notes for __keywords__ and __mfile_encoding__, as those are the formats we generally use for internal functions, and don't know if they need to be called out in the public docs.

Then pushed docstring change for height and width to default as

Passes a make check, marking as ready for test. I think this can probably be closed as fixed.

Nicholas Jankowski <nrjank>
Group Member
Fri 08 Dec 2023 02:25:24 PM UTC, comment #4: 

I pushed the following change on default:


John W. Eaton <jwe>
Group administrator
Fri 08 Dec 2023 01:25:57 PM UTC, comment #3: 

We have the following aliases now (second argument to DEFALIAS is the real function).  The "help name_of_alias" returns the docstring for the real function.  I'm not sure how many of those docstrings note that there is an alias.  I guess it doesn't hurt, but I don't see it as necessary.

$ hg locate | xargs grep ^DEFALIAS
libinterp/corefcn/data.cc:DEFALIAS (isbool, islogical);
libinterp/corefcn/data.cc:DEFALIAS (inf, Inf);
libinterp/corefcn/data.cc:DEFALIAS (nan, NaN);
libinterp/corefcn/data.cc:DEFALIAS (i, I);
libinterp/corefcn/data.cc:DEFALIAS (J, I);
libinterp/corefcn/data.cc:DEFALIAS (j, I);
libinterp/corefcn/data.cc:DEFALIAS (ifelse, merge);
libinterp/corefcn/debug.cc:DEFALIAS (dbnext, dbstep);
libinterp/corefcn/dirfns.cc:DEFALIAS (chdir, cd);
libinterp/corefcn/help.cc:DEFALIAS (__keywords__, iskeyword)
libinterp/corefcn/input.cc:DEFALIAS (__mfile_encoding__, mfile_encoding);
libinterp/corefcn/interpreter.cc:DEFALIAS (exit, quit);
libinterp/corefcn/inv.cc:DEFALIAS (inverse, inv);
libinterp/corefcn/mappers.cc:DEFALIAS (tolower, lower);
libinterp/corefcn/mappers.cc:DEFALIAS (toupper, upper);
libinterp/corefcn/mappers.cc:DEFALIAS (gammaln, lgamma);
libinterp/corefcn/sysdep.cc:DEFALIAS (home, clc);
libinterp/corefcn/sysdep.cc:DEFALIAS (putenv, setenv);

John W. Eaton <jwe>
Group administrator
Fri 08 Dec 2023 01:05:13 PM UTC, comment #2: 

Oops missed that. I only searched open reports. Looks like that would be simple enough to handle any code usage coming our way.  Would an eventual Table class overload of an alias work the same as for an actual function?

Also, can aliases appear in the docs in some way? I assume 'help height' would just silently execute 'help rows'? Is there a correct way to note the alias within the rows/columns docs?

Nicholas Jankowski <nrjank>
Group Member
Fri 08 Dec 2023 12:20:22 PM UTC, comment #1: 

See also bug #50216 but I guess that was submitted when these names were only used for the table class methods.

One possibility is to define aliases:

diff --git a/libinterp/corefcn/data.cc b/libinterp/corefcn/data.cc
--- a/libinterp/corefcn/data.cc
+++ b/libinterp/corefcn/data.cc
@@ -3008,6 +3008,8 @@ This is equivalent to @code{size (@var{A
   return ovl ((octave_value (args(0)).size ())(0));

+DEFALIAS (height, rows);
 %!assert (rows (ones (2,5)), 2)
 %!assert (rows (ones (5,2)), 5)
@@ -3053,6 +3055,8 @@ This is equivalent to @code{size (@var{A
   return ovl ((octave_value (args(0)).size ())(1));

+DEFALIAS (width, columns);
 DEFUN (sum, args, ,
        doc: /* -*- texinfo -*-
 @deftypefn  {} {@var{y} =} sum (@var{x})

John W. Eaton <jwe>
Group administrator
Thu 07 Dec 2023 09:52:05 PM UTC, original submission:  

As of R2020b, Matlab extended the Table class height and width functions for general inputs.  Now for non Table class inputs height and width provide the same function as our rows and columns functions.

height(T) is equivalent to size(T,1)
width(T) is equivalent to size(T,2)


should be a fairly simple compatibility wrapper

Nicholas Jankowski <nrjank>
Group Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by nrjank (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.


    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-12-12 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2023-12-12 nrjank StatusNone Ready For Test
        Planned ReleaseNone 10.1.0 (current default)

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code