bugGNU Octave - Bugs: bug #34123, strtrim no longer trims multilevel...

 
 

bug #34123: strtrim no longer trims multilevel cell arrays in some cases

Submitted by:  Ben Barrowes <barrowes>
Submitted on:  Wed 24 Aug 2011 06:25:03 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: Ben Abbott <bpabbott>
Originator Name: barrowesOpen/Closed: Closed
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Mon 19 Sep 2011 09:37:06 PM UTC, comment #9:

Matlab's online docs can be read to imply that deblank behaves recursively.

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

http://www.mathworks.com/help/techdoc/ref/deblank.html

I don't see than implication on the other cellstr functions I looked at, so I think your conclusion is the correct thing to do.

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Mon 19 Sep 2011 04:31:27 PM UTC, comment #8:

Hmm. Are we chasing Matlab undocumented behavior?

The documentation doesn't make it clear whether deblank and strtrim should work on nested cellstrings or just objects for which iscellstr() returns true. I wonder if it varies by function whether the original programmer thought to code for this case. This would explain why strtrim works in this case and strrep doesn't.

In any case, I will code the same fix used here for deblank and then we can call it quits on Matlab compatibility for now.

Rik <rik5>
Project Administrator
Mon 19 Sep 2011 02:00:26 PM UTC, comment #7:

I check ML's iscellstr() function. It returns a false for multi-level cells of strings.

strrep() also fails in ML

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Mon 19 Sep 2011 12:36:56 PM UTC, comment #6:

Rik, nice inference. Perhaps ML consistently treats cells of cells of strings as cellstings?

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Mon 19 Sep 2011 05:08:48 AM UTC, comment #5:

Sigh. Yes, I was working on a private version of strtrim which accidentally got checked in. I've checked in another changeset to rename the function.

Rik <rik5>
Project Administrator
Mon 19 Sep 2011 03:38:29 AM UTC, comment #4:

Uhm, strtrim2? Is this accidental debug code that got committed?

http://hg.savannah.gnu.org/hgweb/octave/rev/a1049e4480f8#l1.8

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Mon 19 Sep 2011 03:23:16 AM UTC, comment #3:

Fixed in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/a1049e4480f8) along the lines suggested by Ben.

Is there a similar issue in deblank()?

What does Matlab do for the following input

Rik <rik5>
Project Administrator
Sat 17 Sep 2011 01:41:10 AM UTC, comment #2:

cc'n Rik

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Sat 17 Sep 2011 01:35:42 AM UTC, comment #1:

I tested the example with Matlab

I've attached a changeset. It looks a bit inelegant to me.

Is there a better way?

(file #23982)

Ben Abbott <bpabbott>
Project MemberIn charge of this item.
Wed 24 Aug 2011 06:25:03 PM UTC, original submission:

The following just stopped working with the latest dev build. Nested cell arrays no longer get strtrim'ed properly:

debug> aa={' 123 ',{' fg'}}
aa =
{
[1,1] = 123
[1,2] =
{
[1,1] = fg
}
}
debug> strtrim(aa)
error: strtrim: S argument must be a string or cellstring
error: called from:
error: /usr/local/share/octave/3.5.0+/m/strings/strtrim.m at line -1, column -1
debug>

Ben Barrowes <barrowes>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #23982:  changeset.patch added by bpabbott (1KiB - application/octet-stream - first changeset)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by bpabbott (Rik, can you comment on this bug report?)
  • -unavailable- added by bpabbott (Updated the item)
  • -unavailable- added by barrowes (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 19 Sep 2011 04:31:27 PM UTCrik5Open/ClosedOpen=>Closed
    Mon 19 Sep 2011 03:23:16 AM UTCrik5StatusNone=>Fixed
    Sat 17 Sep 2011 01:41:10 AM UTCbpabbottCarbon-Copy-=>Added -unavailable-
    Sat 17 Sep 2011 01:35:42 AM UTCbpabbottAttached File-=>Added changeset.patch, #23982
      Assigned toNone=>bpabbott

    Back to the top


    Powered by Savane 3.1-cleanup1