bugGNU Octave - Bugs: bug #63132, cell input for cell()


bug #63132: cell input for cell()

Submitter:  Guillaume <gyom>
Submitted:  Thu 29 Sep 2022 09:43:25 AM UTC
Category:  Octave Function Severity:  1 - Wish
Priority:  2 Item Group:  Undocumented Matlab
Status:  Fixed Assigned to:  None
Originator Name:  guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Wed 05 Oct 2022 07:40:23 PM UTC, comment #3: 

Thank you for this!

Guillaume <gyom>
Wed 05 Oct 2022 07:19:28 PM UTC, comment #2: 

I pushed the changeset here: http://hg.savannah.gnu.org/hgweb/octave/rev/b8f4ec18e728.

Marking as Fixed and closing report.

Rik <rik5>
Project Administrator
Tue 04 Oct 2022 10:11:53 PM UTC, comment #1: 

This is effectively a no-operation.  I also checked with empty arrays which are not 0x0 and Matlab just passes through the dimensions.  For example,

x = cell (0, 3);
y = cell (x)

y is a 0x3 cell array.

I changed the priority to low since it is easy to workaround (don't call cell() on existing cell arrays).  On the other hand, it wouldn't be that hard to add this functionality.

The issue seems to be this call in ov-cell.cc inside Fcell

    case 1:
      get_dimensions (args(0), "cell", dims);

The call to get_dimensions throws the error.  That function is inside libinterp/corefcn/utils.cc and looks somewhat harder to modify.

I think it is easier just to check whether the input to cell() is already a cell array and pass it to the output if it is.

     case 1:
-      get_dimensions (args(0), "cell", dims);
+      if (args(0).iscell ())
+        return args(0);  // shortcut path for input which is already a Cell
+      else
+        get_dimensions (args(0), "cell", dims);

I'm attaching a cset for this trivial change.

(file #53790)

Rik <rik5>
Project Administrator
Thu 29 Sep 2022 09:43:25 AM UTC, original submission:  

It seems Matlab has a copy constructor for cells:

>> cell ({1})
ans =
  1x1 cell array
>> cell ({})
ans =
  0x0 empty cell array

while Octave doesn't:

>> cell ({1})
error: octave_base_value::array_value(): wrong type argument 'cell'
>> cell ({})
error: cell (A): use cell (size (A)) instead

Guillaume <gyom>


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

Attach Files:

Attached Files
file #53790:  bug63132.cset added by rik5 (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 rik5 (Updated the item)
  • -email is unavailable- added by gyom (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 project members can vote.





    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-05 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2022-10-04 rik5 Attached File- Added bug63132.cset, #53790
        Severity3 - Normal 1 - Wish
        Priority5 - Normal 2
        StatusNone Patch Submitted

    Back to the top

    Powered by Savane 3.9