bugGNU Octave - Bugs: bug #50756, display of objects in cell arrays...

 
 

bug #50756: display of objects in cell arrays and structs is suppressed

Submitted by:  Mike Miller <mtmiller>
Submitted on:  Fri Apr 7 21:35:54 2017  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat Apr 8 18:42:12 2017, comment #5:

Yeah understood. We definitely do want to keep the new behavior of showing the cell indices for each entry, if we keep cell display as it is.

I'd like to also point to #40211 and #43683, which are both about implementing complete overhauls of the way cell arrays are displayed by default. If either of these are done, this may become moot.

Mike Miller <mtmiller>
Project Administrator
Sat Apr 8 16:39:23 2017, comment #4:

My attempt was a quick hack, not to be taken too seriously.

For example, with patch applied

But that is a regression from what we have today

Octave probably still needs to call os.print_with_name, but maybe needs to call display() to fill the temporary buffer buf.

Rik <rik5>
Project Administrator
Sat Apr 8 00:47:27 2017, comment #3:

So if a class intentionally overrides both disp and display, or doesn't override disp, is it correct that we want display(c), where c is a cell array containing an object, to call disp(x) on the object, not display(x)?

The result of this decision is that the screen output of c may appear different from the screen output of c{1}.

I'm pointing this out because both the @pyobject class (in pytave) and the @sym class (in the symbolic package) have both disp and display overrides which give slightly different output. In both cases display does call disp, but it adds a bit of information about the type of the variable in addition to its text representation.

Mike Miller <mtmiller>
Project Administrator
Fri Apr 7 22:36:26 2017, comment #2:

I changed the polynomial code to overload the disp function rather than the display function. This is how things should be done. See cset http://hg.savannah.gnu.org/hgweb/octave/rev/a5280a05b188.

However, that is only a prelude. You are correct that the issue is that the print routine for cells in ov-cell.cc is calling print directly on an octave_value object which does not seem to invoke overloaded version of either display or disp.

I made a quick hack using feval which calls disp() on the octave_value object. This works, but probably only jwe will know if this is the correct approach. See the attached hack.

(file #40326)

Rik <rik5>
Project Administrator
Fri Apr 7 21:45:49 2017, comment #1:

Confirmed.

Rik <rik5>
Project Administrator
Fri Apr 7 21:35:54 2017, original submission:

With the changes that have been made to the way the display method is used, the following no longer shows the value of objects contained in a cell array.

In Octave 4.2.1, with the polynomial class provided in examples/code:

And on the default branch

If we do want the old behavior back, then I guess we need to arrange for octave_cell::print to make sure that the overloaded display method is called for each element that it contains, instead of going straight to its built-in print method.

Mike Miller <mtmiller>
Project Administrator

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #40326:  50756.diff added by rik5 (997B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mtmiller (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon Apr 10 16:47:42 2017rik5Summarydisplay of objects in cell array is suppressed=>display of objects in cell arrays and structs is suppressed
    Fri Apr 7 22:36:26 2017rik5Attached File-=>Added 50756.diff, #40326
    Fri Apr 7 21:45:49 2017rik5StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1