bugGNU Octave - Bugs: bug #39789, Error while indexing certain cell...

 
 

bug #39789: Error while indexing certain cell expressions

Submitter:  None
Submitted:  Thu 15 Aug 2013 08:24:47 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Alexander Mamonov Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.4
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 18 Jan 2016 05:03:01 PM UTC, comment #5: 

@Lachlan: I checked in your fix for indexing cell expressions here (http://hg.savannah.gnu.org/hgweb/octave/rev/99d373870017).  I benchmarked before/after and I couldn't detect a performance difference.  One thing I did was add regression tests for this bug and bug #35841 to index.tst so that we don't accidentally re-introduce this bug if we optimize things in the future.

Rik <rik5>
Group administrator
Wed 16 Dec 2015 01:18:23 AM UTC, comment #4: 

It is even easier to resolve, although I'm not sure if the resolution is correct :)

For some reason, the function

Array<T>::index (const Array<idx_vector>& ia, bool resize_ok, const T& rfv) const

had two checks that the dimension of  ia  matches that of this.  First, it correctly expands trailing singletons, but in the second check it doesn't.

My current work-around is to do the second test only if a resize occurs, but since I'm not sure why the test is needed at all, that may not be the right response.

This also avoids the problem of bug #35841 directly, and so the attached changeset backs that fix out (while keeping the changes to tests).


(file #35756)

Lachlan Andrew <lachlan>
Thu 26 Nov 2015 05:42:03 PM UTC, comment #3: 

@Lachlan: Adding you to the CC list for this bug about cell indexing with trailing singleton dimensions.  This looks awfully similar to bug #35841 which dealt with the assignment to structs with trailing singleton dimensions.  You prepared the changeset for that here http://hg.savannah.gnu.org/hgweb/octave/rev/96163bdd2ea1.  Could you take a look and see if it is equally easy to resolve?

Rik <rik5>
Group administrator
Sun 25 Aug 2013 08:33:40 AM UTC, comment #2: 

Looks like the issue is with octave failing to allow the second level of indexing in this case.  In matlab:

>> c{1} = zeros(3,2);
>> c{1,1,1,1,1}(:,1)=1;
>> c{1}
ans =
     1     0
     1     0
     1     0

in octave:

octave:1> c{1} = zeros(3,2);
octave:2> c{1,1,1}(:,1) = 1
error: a cs-list cannot be further indexed
error: assignment failed, or no method for 'cell = scalar'
octave:2> c{1,1}(:,2) = 2
c =
{
  [1,1] =
     0   2
     0   2
     0   2
}
octave:3> c{1,1,1,1,1}
ans =
   0   2
   0   2
   0   2


Ben Kurtz <bkurtz>
Tue 20 Aug 2013 05:08:25 AM UTC, comment #1: 

Confirmed on a recent development tip (hg id bc924baa2c4e).  The issue is with how trailing dimensions are treated, and it would be useful to know how Matlab behaves for the same code input if you have access to it.

The code


c = cell (1,1,1);


does not create a 1x1x1 cell array.  In Octave and Matlab trailing singleton dimensions are usually removed so this becomes


c = cell (1,1);


This can be checked with


c = cell (1,1,1);
size (c)
ans =

   1   1


Your code sample works if the cell array is truly 3-dimensional.


c = cell (1,1,2);
c{1,1,1} = zeros (5,2);
c{1,1,1}(:, 1) = 1;


Rik <rik5>
Group administrator
Thu 15 Aug 2013 08:24:47 AM UTC, original submission:  

When executing the following cell assignment


c = cell(1,1,1);
c{1,1,1} = zeros(5, 2);
c{1,1,1}(:, 1) = 1;


Octave gives an error:

error: a cs-list cannot be further indexed
error: assignment failed, or no method for 'cell = range'

Expected behavior is for c{1,1,1} to assume value
[1, 0; 1, 0; 1, 0; 1, 0; 1, 0]

If this bug is fixed, please add a relevant test to the test suite.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #35756:  bug_39789.cset added by lachlan (3KiB - application/octet-stream)
file #28848:  testcell111.m added by None (64B - 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
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (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
    2016-01-18 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-12-16 lachlan Attached File- Added bug_39789.cset, #35756
    2015-11-26 rik5 Carbon-Copy- Added lachlan
    2013-08-20 rik5 StatusNone Confirmed
    2013-08-15 None Attached File- Added testcell111.m, #28848

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code