bugGNU Octave - Bugs: bug #35841, error assigning value to multi-dim...

 
 

bug #35841: error assigning value to multi-dim struct with trailing singleton dimensions

Submitter:  None
Submitted:  Wed 14 Mar 2012 05:35:11 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Ray Zimmerman Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 25 Sep 2018 08:07:25 PM UTC, comment #6: 

Never mind.  Found a glitch elsewhere that explained the peculiar behavior. 
The program is handling all these trailing singleton dimensions just perfectly!!

Ron Salomon <greenbriar>
Tue 25 Sep 2018 07:27:55 PM UTC, comment #5: 

I think I've run into this glitch again while loading a cell with 2D matrices with variable numbers of columns, always the same number of rows.
The cell dimensions are 9,3,12,2.
All arrays load fine except, as far as I can tell, just one:  the cell 6,1,1,1 won't take the assigned array. 

PS - further study shows it is not the loading that's a problem, it's retrieval. 
CELL{6,1,1,1}(4:end,:) gives ans = {}(0x1).
CELL{6,1,1,1} gives the expected 2D array.
However, for example,
CELL{5,1,1,1}(4:end,:) gives the expected 2D array.

I can code a work-around, but this might affect others!

Ron Salomon <greenbriar>
Tue 25 Sep 2018 07:18:39 PM UTC, comment #4: 

I think I've run into this glitch again while loading a cell with 2D matrices with variable numbers of columns, always the same number of rows.
The cell dimensions are 9,3,12,2.
All arrays load fine except, as far as I can tell, just one:  the cell 6,1,1,1 won't take the assigned array. 


Ron Salomon <greenbriar>
Tue 13 Oct 2015 04:58:36 PM UTC, comment #3: 

I modified the patch slightly.  Octave core uses spaces, rather than tabs, for indenting.  I also the failing code from this bug report as a test in test/struct.tst so that we don't re-introduce this behavior at a later date.  I checked in the patch under Lachlan's name on the development branch (http://hg.savannah.gnu.org/hgweb/octave/rev/96163bdd2ea1).

Rik <rik5>
Group administrator
Thu 24 Sep 2015 01:02:42 PM UTC, comment #2: 

The attached patch makes the original poster's code work, although I'm not sure if it is the right approach.

The problem seems to be that
  map.contents (pkey).index (idx.front (), true)
has 0 elements in this case.  It may be that the appropriate fix is to make sure that returns something with 1 element in this case.  However, a work-around is to set tmpc = Cell(1,1) when it is empty.

The attach also fixes a problem with

octave> a(1,1,1).b = 1;
octave> a(1,1,:).b = 1
error: invalid assignment to cs-list outside multiple assignment
error: assignment failed, or no method for 'scalar struct = scalar'

In this case, it is sufficient to ignore the fact that the map index is empty.

(file #34973)

Lachlan Andrew <lachlan>
Wed 14 Mar 2012 06:58:27 PM UTC, comment #1: 

Confirmed on a recent development tip.

This bug is most likely related to singleton dimensions.

The following works which uses only two dimensions


a(1,1).b(1) = 2;
a(1,1).b(1) = 3;


And the reporter has already shown that if the final index is not a singleton then the code works correctly.

Rik <rik5>
Group administrator
Wed 14 Mar 2012 05:35:11 PM UTC, original submission:  

I'm guessing this is a bug. The latest version I have to test this on is 3.4.0, so I'm not sure if it's still an issue in the current release. Starting with a and b undefined ...


octave-3.4.0:3> a(1,1,1).b(1) = 2;
octave-3.4.0:4> a(1,1,1).b(1) = 3;
error: a cs-list cannot be further indexed
error: assignment to structure element failed
error: assignment failed, or no method for `scalar struct = scalar'


The above produces no error in Matlab.

I think it's related to the singleton dimensions ...


octave-3.4.0:4> a(1,1,2).b(1) = 2;
octave-3.4.0:5> a(1,1,1).b(1) = 2;


... works just fine.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #34973:  bug35841.patch added by lachlan (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by greenbriar (Posted a comment)
  • -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)
  •  

    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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-26 mtmiller Carbon-CopyRemoved 80942 -
    2015-10-13 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2015-09-24 mtmiller StatusConfirmed Patch Submitted
    2015-09-24 lachlan Attached File- Added bug35841.patch, #34973
    2015-01-31 mtmiller Release3.4.0 dev
        Operating SystemMac OS Any
        Summaryerror assigning value to multi-dim struct error assigning value to multi-dim struct with trailing singleton dimensions
    2012-03-14 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code