bugGNU Octave - Bugs: bug #51410, display of multidimensional arrays...

 
 

bug #51410: display of multidimensional arrays uses 'ans'

Submitter:  Guillaume <gyom>
Submitted:  Fri 07 Jul 2017 09:02:14 AM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  Other
Status:  Confirmed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 23 Oct 2019 10:12:48 PM UTC, comment #7: 

Another issue is that each page of the array may use an individual format.  For example, I see this:


octave:2> x = cat (3, rand(2)*1000, rand(2)/1000)
x =

ans(:,:,1) =

   402.19   248.27
   259.84   826.15

ans(:,:,2) =

   6.0208e-04   9.3665e-04
   5.1218e-04   2.6246e-04


Is that what people want?  Should I open a separate bug report for that?

John W. Eaton <jwe>
Group administrator
Wed 23 Oct 2019 10:12:47 PM UTC, comment #6: 

In the Symbolic package, I needed to modify the "ans = " bit to render like "ans(x) = " (in a subclass).

The superclass display.m has:

  % weird hack to support "ans(x) = " output for @symfun
  name = private_disp_name(x, inputname (1));



https://github.com/cbm755/octsympy/blob/master/inst/%40sym/display.m
https://github.com/cbm755/octsympy/blob/master/inst/%40sym/private_disp_name.m
https://github.com/cbm755/octsympy/blob/master/inst/%40symfun/private_disp_name.m

I'm not suggesting this is a solution to the problem here but it at least shows much many hoops pkg/OO developers will jump through to tweak the display...

Colin Macdonald <cbm>
Wed 23 Oct 2019 09:49:34 PM UTC, comment #5: 

From my initial look at bug #56974, it is going to require a fair bit of modification of the print system.  As long as we are doing that, we should identify all other display issues and see if we can fix them as well.

Rik <rik5>
Group administrator
Wed 23 Oct 2019 09:18:00 PM UTC, comment #4: 

This problem has some overlap with bug #56974.  Maybe both should be fixed at the same time.



John W. Eaton <jwe>
Group administrator
Mon 10 Jul 2017 09:18:58 AM UTC, comment #3: 

Thanks for the feedback, Rik.

I thought something like this might be taking place. Maybe something to keep in mind if the relevant functions are one day refactored otherwise, as you say, very low priority.

Guillaume <gyom>
Mon 10 Jul 2017 04:45:30 AM UTC, comment #2: 

The code is in libinterp/corefcn/pr-output.cc beginning at line 2032 (dev branch).


          std::string nm = "ans";

          if (m > 1)
            {
              nm += "(:,:,";


Unfortunately, the way Octave printing works is to show the initial name and equals sign (for example, "myvar =\n\n"), but after that the rest of the printing routines have no idea what the name of the variable being printed is.  To fix this would require changing the function prototype for not just print_nd_array, but octave_print_internal which has many variations.  I'm not sure it is worth that effort.  

Rik <rik5>
Group administrator
Mon 10 Jul 2017 04:31:25 AM UTC, comment #1: 

Confirmed.  It would be better to use the variable name rather than "ans" for clarity.

Rik <rik5>
Group administrator
Fri 07 Jul 2017 09:02:14 AM UTC, original submission:  

When an array of more than two dimensions is displayed, 'ans' is used for the name of the variable:


octave:15> a = rand (3,3,2)
a =

ans(:,:,1) =

   0.462941   0.802606   0.761311
   0.922112   0.916468   0.987126
   0.963205   0.593986   0.087091

ans(:,:,2) =

   0.42108   0.69784   0.62200
   0.16416   0.16271   0.11518
   0.41170   0.75955   0.64193


This is a little bit misleading as there is no variable 'ans':


octave:16> whos
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        a           3x3x2                      144  double

Total is 18 elements using 144 bytes


In comparison, Matlab displays the following:


>> a = rand (3,3,2)

a(:,:,1) =

    0.2498    0.2543    0.3066
    0.9429    0.8063    0.4474
    0.6879    0.9031    0.8050


a(:,:,2) =

    0.9369    0.2796    0.9091
    0.1507    0.6469    0.1390
    0.5728    0.2529    0.1284


Guillaume <gyom>

 

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

Attach Files:
   
   
Comment:
   

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 cbm (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by amro_octave
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-20 mtmiller CategoryNone Interpreter
    2017-07-14 amro_octave Carbon-Copy- Added amro_octave
    2017-07-10 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.14-8eb0.
    Corresponding source code