bugGNU Octave - Bugs: bug #60867, `whos` doesn't show sparse...

 
 

bug #60867: `whos` doesn't show sparse attribute

Submitter:  Markus Mützel <mmuetzel>
Submitted:  Thu 01 Jul 2021 07:15:17 AM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
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:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 06 Jul 2021 06:14:00 PM UTC, comment #7: 

I pushed the patch with left-adjusted attribute field here http://hg.savannah.gnu.org/hgweb/octave/rev/56b3e2af0298.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Tue 06 Jul 2021 06:41:43 AM UTC, comment #6: 

Personally, I prefer the arraignment in comment #5 over the one in comment #4.

If you agree, please go ahead an push a modified patch.

Markus Mützel <mmuetzel>
Group administrator
Mon 05 Jul 2021 09:17:11 PM UTC, comment #5: 

The format for the printed text from `whos` can be configured with `whos_line_format`.  Try `help whos_line_format`.

To left-justify a field you just need to add 'l' to the format specifier.  For example,


new_fmt = "  %la:5; %ln:6; %cs:16:6:1;  %rb:12;  %lc:-1;\n";
whos_line_format (new_fmt)


The results with a complex, sparse, persistent variable are


  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
  cs  p  myvar       1x1                         40  double


Is that better?  Can always add this to the changeset as well.

Rik <rik5>
Group administrator
Sun 04 Jul 2021 09:45:06 AM UTC, comment #4: 

Thanks.
That looks good to me.

The other columns in the output of `whos` containing text are left aligned. The "Bytes" column is right aligned (which seems good to me). Should the "Attr" column be left aligned like the other text columns? Or should it be right aligned like it seems to be currently (at least for the heading)?

>> test_persist
Variables visible from the current scope:

variables in scope: test_persist: /home/osboxes/Documents/Repositories/Octave/octave-2/.build/test_persist.m

    Attr Name          Size                     Bytes  Class
    ==== ====          ====                     =====  =====
   cs  p test_var      1x1                         40  double

Total is 1 element using 40 bytes


But that is probably something that we could also decide on at a later point.


Markus Mützel <mmuetzel>
Group administrator
Thu 01 Jul 2021 10:35:28 PM UTC, comment #3: 

Made a small change to the documentation.  See second patch file.

(file #51639)

Rik <rik5>
Group administrator
Thu 01 Jul 2021 10:31:33 PM UTC, comment #2: 

Attached is a first try at implementing this feature.  It seems to work, although I'm not sure I quite like the arrangement of attributes on the left-hand side.



(file #51638)

Rik <rik5>
Group administrator
Thu 01 Jul 2021 06:07:36 PM UTC, comment #1: 

I totally agree.  This would be a nice addition to Octave.  If you type `help whos` you can find a list of the existing attributes.


     Attr
          Attributes of the listed variable.  Possible attributes are:

          blank
               Variable in local scope

          'c'
               Variable of complex type.

          'f'
               Formal parameter (function argument).

          'g'
               Variable with global scope.

          'p'
               Persistent variable.


I would propose 's' for "Sparse variable".

Rik <rik5>
Group administrator
Thu 01 Jul 2021 07:15:17 AM UTC, original submission:  

In the output printed by the function `whos` there is no easy way to see immediately if a matrix is full or sparse:

>> a = 1;
>> b = sparse(1);
>> whos
Variables visible from the current scope:

variables in scope: top scope

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        a           1x1                          8  double
        b           1x1                         32  double

Total is 2 elements using 40 bytes


Matlab R2021a shows the sparse attribute in a similar table:

>> a = 1;
>> b = sparse(1);
>> whos
  Name      Size            Bytes  Class     Attributes

  a         1x1                 8  double
  b         1x1                32  double    sparse

>>


It would be nice if Octave could do something similar.

Markus Mützel <mmuetzel>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #51639:  60687.patch2 added by rik5 (4KiB - application/octet-stream)
file #51638:  60687.patch added by rik5 (4KiB - text/x-patch)

 

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 mmuetzel (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-07-06 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2021-07-01 rik5 Attached File- Added 60687.patch2, #51639
    2021-07-01 rik5 Attached File- Added 60687.patch, #51638
        StatusConfirmed Patch Submitted
    2021-07-01 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code