bugGNU Octave - Bugs: bug #34038, deblank does not work on indexed...

 
 

bug #34038: deblank does not work on indexed cells

Submitter:  Ben Barrowes <barrowes>
Submitted:  Wed 17 Aug 2011 06:32:14 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Ben Barrowes Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 22 Aug 2011 05:21:22 AM UTC, comment #4: 

Seems to me that the docstring is still unclear. "Recursive" to me suggest the following should work:


a = {"  foo  ", {" bar  ", {"baz  "}}};
deblank(a)


but it doesn't. What's wrong, the docstring or the function?

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Mon 22 Aug 2011 04:53:58 AM UTC, comment #3: 

The Octave docstring is old and seems to have been written when there was not much distinction between a cell and a cell array of strings. 

The deblank() documentation for ML (http://www.mathworks.com/help/techdoc/ref/deblank.html) is much clearer.  It specifies only two calling forms.  One for character arrays and one for cellstrs.


c = deblank(c) when c is a cell array of strings, applies deblank to each element of c.


I've added a changeset which clarifies that cell arrays of strings, not cells alone, are the desired input.  I also added notes to the NEWS file since a number of the functions in the strings directory have been reworked.  http://hg.savannah.gnu.org/hgweb/octave/rev/4ec4096f65d1

Rik <rik5>
Group administrator
Fri 19 Aug 2011 05:45:59 AM UTC, comment #2: 

Was this the right fix? The docstring says deblank should operate recursively on cell arrays, not just cellstrings, and this is a regression from 3.4.2 in which this command did work as Ben expected it to. The deblank function used to only warn when being passed non-string arguments, but erroring out seems too severe to me. I think GIGO with warning is fair game.

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Fri 19 Aug 2011 05:29:39 AM UTC, comment #1: 

Octave, in general, is more careful about checking its inputs than Matlab.  More often than not this is a good thing because it prevents Garbage In/Garbage Out where you thought you were feeding something compatible to a function but in fact were not.

In this case, Octave should not have allowed a cell as input.  The function only works properly for character arrays and cellstrings.  I've checked in a changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/f89449967f0d) which enforces this.

Rik <rik5>
Group administrator
Wed 17 Aug 2011 06:32:14 PM UTC, original submission:  

Octave produces an error when a index cell is passed to deblank.




In octave:

octave:6> aa=cell(1,2)
aa =
{
  [1,1] = [](0x0)
  [1,2] = [](0x0)
}
octave:7> deblank(aa)
warning: implicit conversion from matrix to sq_string
warning: implicit conversion from matrix to sq_string
warning: implicit conversion from matrix to sq_string
warning: implicit conversion from matrix to sq_string
ans =
{
  [1,1] = [](0x0)
  [1,2] = [](0x0)
}
octave:8> deblank(aa{1})
error: deblank: S argument must be a string or cellstring
error: called from
    deblank at line 50 column 5
stopped in /usr/local/share/octave/3.5.0+/m/strings/deblank.m
debug>







While in matlab:

>> aa=cell(1,2)

aa =
    []    []

>> deblank(aa)

ans =
    []    []

>> deblank(aa{1})

ans =
     []

>>

Ben Barrowes <barrowes>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by barrowes (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
    2011-08-19 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
        Summarydebalnk does not work on indexed cells deblank does not work on indexed cells

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code