bugGNU Octave - Bugs: bug #42152, Overloaded vercat() not called in...

 
 

bug #42152: Overloaded vercat() not called in some other cases

Submitter:  Colin Macdonald <cbm>
Submitted:  Sun 20 Apr 2014 03:56:53 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  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

Fri 13 Jul 2018 07:16:12 AM UTC, comment #6: 

Yes it is a Matlab compatibility issue: Symbolic works on Matlab and only has @sym/horzcat and @sym/vertcat.

Colin Macdonald <cbm>
Thu 19 Apr 2018 05:52:36 PM UTC, comment #5: 

I had to read back a bit to refresh myself on this bug, but I think #3 should be fixed in Octave. This is probably a Matlab compatibility issue, isn't it? Have you or has someone tested in Matlab to see if defining @foo/vertcat.m is enough to allow this to work?

I think adding a '@double/horzcat.m' is only a small hack, because this will surely fail again with [x; int32(1), int32(2)].

Mike Miller <mtmiller>
Group Member
Thu 19 Apr 2018 04:51:05 AM UTC, comment #4: 

@mtmiller, sorry for leaving this so long.  Do you think:

1.  Symbolic should ship such an @double/horzcat.m, as a workaround.
2.  Core Octave should ship such a file.
3.  Core Octave should fix "builtin cat methods are not looked up properly in a class context."

Colin Macdonald <cbm>
Mon 22 May 2017 11:06:26 PM UTC, comment #3: 

That should have been "@double/horzcat" in my second bullet point.

Actually creating a @double/horzcat.m function with the following body


function y = horzcat(varargin)
  y = builtin('horzcat', varargin{:});
end


actually fixes this issue completely. Because the method can be resolved, the class concatenation can succeed on the non-class double type, and the resulting class array is finished correctly.

I would characterize this bug slightly differently than the current summary, instead of the fact that the overloaded vertcat method is not being called, it's more accurate to say that class-based concatenation of a row of primitive types fails because the builtin cat methods are not looked up properly in a class context.

Mike Miller <mtmiller>
Group Member
Mon 22 May 2017 10:31:47 PM UTC, comment #2: 

I've started digging into this bug. Some notes so far:

  • The syntax "[x; [1 2]]" is understood by the parser as three separate concatenation operations. First, a 1×2 concatenation of the second row, consisting entirely of 1×1 doubles, which results in a double row vector. Second, a "vertcat" concatenation of the class value "x" with the double array [1 2]. And third, the nested "vertcat" concatenation of double arrays that happens inside the overloaded "vertcat" method of the A class.


  • The syntax "[x; 1 2]" is understood by the parser as a single concatenation operation which fails, as we know. The difference is the concatenation is being done on the rows of the matrix as an overall class type, rather than being done separately on the second row as a double type. Since the result type is expected to be a class, the function do_class_concat is called on each row. When do_class_concat gets a row that is entirely scalar doubles, it doesn't know what to do with them and the error is thrown (at libinterp/corefcn/data.cc line 1742). The conversion code assumes that because there is no @double/vertcat method explicitly defined, it must try to convert these objects to structs and concatenate them.


So this seems like a circular limitation, in that we do have a way to call vertcat on a list of doubles, but it is not recognized as a class method, so the class concatenation code can't operate on doubles.

Mike Miller <mtmiller>
Group Member
Wed 23 Jul 2014 03:24:34 PM UTC, comment #1: 

I hit this again, so spent a little time on it...  Sorry no fix, but here's the test at least.

Its a patch to classes.tst to exhibits this on the Snork class.  The failures are marked with xtest, following what I saw in Bug #38128.


(file #31764)

Colin Macdonald <cbm>
Sun 20 Apr 2014 03:56:53 PM UTC, original submission:  

x is a member of a class with a overloading vertcat.


z7 = [x; [1 2]]   % works (bug #38128)
z8 = [x; 1 2]     % fails


For details, look at bug #38128, consider the example given there in the OP.  Those do work correctly.

The error message is:

error: octave_base_value::map_value(): wrong type argument 'scalar'
error: octave_base_value::parent_class_name_list(): wrong type argument 'scalar'


I attach the files for the class, essentially from bug #38128 with typo fixed and double.m added.

Colin Macdonald <cbm>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #31764:  bug42152.diff added by cbm (2KiB - text/x-patch)
file #31219:  A.m added by cbm (60B - text/x-objcsrc)
file #31220:  vertcat.m added by cbm (62B - text/x-objcsrc)
file #31221:  double.m added by cbm (35B - text/x-objcsrc)

 

Carbon-Copy List
  • -email is unavailable- added by doronbehar
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by cbm (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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-30 mmuetzel Dependencies- bugs #42282 is dependent
    2020-03-26 doronbehar Carbon-Copy- Added doronbehar
    2018-09-10 mtmiller Dependencies- bugs #54641 is dependent
    2017-05-22 mtmiller StatusNone Confirmed
    2015-09-09 mtmiller Dependencies- bugs #45904 is dependent
    2015-07-04 carandraug Dependencies- bugs #45423 is dependent
    2014-07-23 cbm Attached File- Added bug42152.diff, #31764
    2014-04-20 cbm Attached File- Added A.m, #31219
        Attached File- Added vertcat.m, #31220
        Attached File- Added double.m, #31221

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code