bugGNU Octave - Bugs: bug #51448, cell2mat doesn't preserve...

 
 

bug #51448: cell2mat doesn't preserve dimensions of empty input

Submitter:  Olaf Till <i7tiol>
Submitted:  Wed 12 Jul 2017 07:03:10 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Olaf Till Open/Closed:  * Closed
Release:  * 4.2.1 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 22 Sep 2018 04:48:40 PM UTC, comment #2: 

I recently upgraded my parallel package to the new version that contains this bug fix. After that, the package stopped working.

Commenting out line 452 of the parcellfun.m fixes the code for me.

To give some context, my algorithm running in parallel outputs matrices (n x 10), where "n" depends on the inputs of the algorithm. Then, this algorithm is run in parallel with m process using the pararrayfun.m. At the end, I expect to obtain an output with the dimension (n x 10m), where the outputs from the different parallel runs are concatenated into the column. So, I expect pararayfun.m to return me an (n x 10m) matrix. This was working as expected before I upgraded the parallel package (I believe it was version 3.1.1).

What I observed on my debugging was that, when the code gets in line 452 of parcellfun.m, varargout{i} already has the output dimension (n x 10m), which was obtained when running "varargout{i} = cell2mat (res(i, :));" in line 448. So, it breaks when it runs "varargout{i} = reshape (varargout{i}, shape);" in line 452 because "size(shape) = [1 m]" and "size(varargout{i}) = [n 10m]", which means it cannot reshape varargout{i} to [1 m].

Hugo Milan <hugomilan>
Thu 13 Jul 2017 04:11:47 AM UTC, comment #1: 

I made a few changes, testing for isempty rather than numel == 0, and I added a BIST test for the correct behavior.  I checked in the change on the development branch here (http://hg.savannah.gnu.org/hgweb/octave/rev/82886a27ce3a).  Thanks for noticing this.

Rik <rik5>
Group administrator
Wed 12 Jul 2017 07:03:10 AM UTC, original submission:  

(Probably affects development branch also.)

'cell2mat' doesn't preserve dimensions of empty input, e.g.

cell2mat (cell (2, 0))

should return

ans = [](2x0)

but currently returns

ans = [](0x0)


Patch follows as soon as I know the bug number.

Olaf Till <i7tiol>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #41184:  cell2mat-51448.cset added by i7tiol (926B - 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 hugomilan (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by i7tiol (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-07-13 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2017-07-12 i7tiol Attached File- Added cell2mat-51448.cset, #41184

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code