bugGNU Octave - Bugs: bug #51634, Calling repmat on struct array...

 
 

bug #51634: Calling repmat on struct array with explicit trailing singleton dimensions fails

Submitter:  Piotr Held <jsoh425>
Submitted:  Mon 31 Jul 2017 11:12:58 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Piotr Held Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 05 Aug 2017 04:14:32 AM UTC, comment #4: 

I added another BIST test for one of the other bugs and checked in the patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/3544f88a2bb5).  Marking as fixed and closing report.

Rik <rik5>
Group administrator
Sat 05 Aug 2017 04:04:03 AM UTC, comment #3: 

@Piotr: Thanks for noticing this and providing such a simple fix.  There are at least two other bug reports about this.  I'm going to link them to this and then close all of them.

Rik <rik5>
Group administrator
Wed 02 Aug 2017 09:16:46 PM UTC, comment #2: 

This issue is actually connected to reshape, I apologize for not being more precise earlier.

The following code fails:


 a = struct ('f', 1);
 a = repmat (a, 3, 1);
 reshape (a, 1, 3, 1, 1);


I am attaching this code in 'repmat_struct.tst' as a test.

The problem is with octave_map::reshape, that didn't chop trailing singletons for the main struct-array dimension.

The patch changeset also includes a test that is placed directly below octave_map::reshape and did not pass prior to patch and does pass after patch.

(file #41397)

Piotr Held <jsoh425>
Mon 31 Jul 2017 11:22:10 PM UTC, comment #1: 

I was also able to add a test to octave_map::reshape() which did not pass prior to my change and now passes.

I am attaching the changeset.

(file #41378)

Piotr Held <jsoh425>
Mon 31 Jul 2017 11:12:58 PM UTC, original submission:  

The exact code is as follows:


a = struct('f',1);
b = repmat (a, 3, 1);
c = repmat (b, 1, 3); % this line fails


I believe I have identified the problem and I will attach a changeset in the next post.

I believe the problem is with octave_map::reshape(const dim_vector&). When reshaping the octave map the main dimensions (retval.dimensions) do not have the singletons chopped. Whereas, when reshaping the values (retval.xvals) the trailing singletons are chopped (the Array constructor does that). So the failure occured when trying to compare the main dimensions (retval.dimensions) to the array value dimensions (retval.xvals).

A simple:


retval.dimensions.chop_trailing_singletons ();


seems to solve the trick.

Piotr Held <jsoh425>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #41397:  repmat_struct.tst added by jsoh425 (272B - application/octet-stream)
file #41378:  patch_bug51634.diff added by jsoh425 (1KiB - text/x-patch)

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jordigh (Updated the item)
  • -email is unavailable- added by jsoh425 (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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-08-05 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2017-08-05 rik5 Dependencies- Depends on bugs #43650
    2017-08-05 rik5 Dependencies- Depends on bugs #46385
    2017-08-02 jsoh425 Attached File- Added repmat_struct.tst, #41397
    2017-08-02 jordigh Item GroupIncorrect Result Regression
        SummaryCalling repmat on struct array sometimes fails Calling repmat on struct array with explicit trailing singleton dimensions fails
    2017-07-31 jsoh425 Attached File- Added patch_bug51634.diff, #41378

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code