bugGNU Octave - Bugs: bug #43511, null array retained when cellstr...


bug #43511: null array retained when cellstr is used to build vector through concatenation

Submitted by:  None
Submitted on:  Fri 31 Oct 2014 10:02:14 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  Lachlan Andrew <lachlan>
Originator Name:  Kelvin McCollough Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  dev
Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

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


( Jump to the original submission)

Mon 15 Feb 2016 06:47:56 PM UTC, comment #11: 

I committed the patch here.

I changed

if (p->dims ().zero_by_zero ())


if (p->is_empty ())

because it seems that any empty matrix should be suppressed and that

a = 'example';
b = zeros (2,0);
b = [b, cellstr(a)]
b => 'example';

It also created a failing test in copyobj.m.  That seems to have been potentially unclear coding that was vulnerable to the change in definition.  I fixed that too.

Rik <rik5>
Project Administrator
Mon 08 Feb 2016 06:53:04 PM UTC, comment #10: 

I've tested it and reported / edited the bug overview you and Avinoam made in the wiki some day ago. AFAIR it worked well.
I didn't push yet due to lack of time (testing is one thing, can be done in between, but with pushing I always try to be extra cautious)

Did I understand well that you've been given push credentials? If so, congratulations! very well.
(and if not so, it would be about time you would get it IMO)

Philip Nienhuis <philipnienhuis>
Project Member
Tue 26 Jan 2016 04:54:49 AM UTC, comment #9: 

The attached patch fixes the problem reported.

It makes constructs such as [ [], {1}; {2}, {3} ] illegal, since the rows have different numbers of elements.  I assume that is the desired behaviour.

(file #36166)

Lachlan Andrew <lachlan>In charge of this item.
Fri 20 Nov 2015 01:47:49 PM UTC, comment #8: 

This also occurs in the released Octave 4.0.0

Thu 19 Mar 2015 10:01:13 PM UTC, comment #7: 

Matlab r2015a behaves the same as r2012a.

Philip Nienhuis <philipnienhuis>
Project Member
Sat 08 Nov 2014 10:36:00 PM UTC, comment #6: 

Sure, here is the result:

>> [ [], {1}, [], {2}, [] ]

ans =

    [1]    [2]

>> ver
MATLAB Version: (R2012a)

I've marked it as a regression :-)

Philip Nienhuis <philipnienhuis>
Project Member
Fri 07 Nov 2014 03:57:53 PM UTC, comment #5: 

Well, at least the behavior seems to be generalized to concatenation with any cell.

@Philip: Could you make one more test?  I don't think the first entry is special, but I want to verify that Matlab removes all null matrices wherever they appear in the list.

The following example in the development version of Octave produces:

[ [], {1}, [], {2}, [] ]
ans =
  [1,1] = [](0x0)
  [1,2] =  1
  [1,3] = [](0x0)
  [1,4] =  2
  [1,5] = [](0x0)

Under Octave 3.4.3 it produces

[ [], {1}, [], {2}, []]
ans =
  [1,1] =  1
  [1,2] =  2

If Matlab is the same as 3.4.3 then I think we should mark this bug as a regression.

Rik <rik5>
Project Administrator
Fri 07 Nov 2014 12:13:33 PM UTC, comment #4: 

Forgot (comment #3): r2012a 32-bit

Philip Nienhuis <philipnienhuis>
Project Member
Fri 07 Nov 2014 12:13:06 PM UTC, comment #3: 

Yes it does strip it out.
(I can't copy results verbatim, as my ML prerelease timed out and I ran the commands in passing while being logged in remotely at work.)

Philip Nienhuis <philipnienhuis>
Project Member
Mon 03 Nov 2014 04:28:22 AM UTC, comment #2: 

I don't think there is any difference between cellstr and regular cells arrays, but could someone check the following concatenation in Matlab?

a = 1;
b = [];
c = [b, {a}]

Does this also strip out the null matrix b?

Rik <rik5>
Project Administrator
Fri 31 Oct 2014 10:11:41 PM UTC, comment #1: 

Matlab r2014b prerelease does (empty lines removed):

>> a = 'example'
a =
>> b = []
b =
>> b = [b cellstr(a)]
b =

...so yes, Octave (just checked in 4.1.0+ too) behaves at least ML-incompatible.

Release => dev, OS => any, title (Summary) adapted a little

Philip Nienhuis <philipnienhuis>
Project Member
Fri 31 Oct 2014 10:02:14 PM UTC, original submission:  

octave:14> a = "example"
a = example
octave:15> b = []
b = [](0x0)
octave:16> b = [b, cellstr(a)]
b =
  [1,1] = [](0x0)
  [1,2] = example

Version 3.4.3 and older matlab versions would return

octave:62> a = "example"
a = example
octave:63> b = []
b = [](0x0)
octave:64> b = [b, cellstr(a)]
b =
  [1,1] = example
octave:65> version
ans = 3.4.3



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

Attach Files:

Attached Files
file #36166:  bug_43511.cset added by lachlan (1KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by lachlan (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

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

    Only project members can vote.




    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-15 rik5 StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2016-02-08 lachlan Assigned toNone => lachlan
    2016-02-08 lachlan StatusConfirmed => Patch Submitted
    2016-01-26 lachlan Attached File- => Added bug_43511.cset, #36166
    2014-12-06 rik5 Summarynull arrary retained when cellstr is used to build vector through concatenation => null array retained when cellstr is used to build vector through concatenation
    2014-11-08 philipnienhuis Item GroupMatlab Compatibility => Regression
    2014-10-31 philipnienhuis StatusNone => Confirmed
        Release3.8.2 => dev
        Operating SystemGNU/Linux => Any
        Summarynull arrary to be retained when cellstr is used to build vector through concatenation => null arrary retained when cellstr is used to build vector through concatenation

    Back to the top

    Powered by Savane 3.6