bugGNU Octave - Bugs: bug #33334, Concatenation cell strings and...

 
 

bug #33334: Concatenation cell strings and strings

Submitted by:  David Bateman <dbateman>
Submitted on:  Tue 17 May 2011 08:30:04 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: David BatemanOpen/Closed: Closed
Release: 3.4.0Operating System: GNU/Linux

Add a New Comment (Rich MarkupRich 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)

Wed 09 May 2012 06:43:27 AM UTC, comment #9:

This one seems to be fixed. Can this be closed now?

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Wed 18 May 2011 09:41:49 PM UTC, comment #8:

Matlab has its mysterious ways. Here is the latest:

>> version


ans =

7.9.0.529 (R2009b)

>> ['s1', {[1,1]}]


ans =

's1' [1x2 double]

>> [{[1,1]}, 's1']


ans =

[1x2 double] 's1'

>>

Michael Godfrey <godfrey>
Wed 18 May 2011 09:16:07 PM UTC, comment #7:

Well if you want to know the results weren't what I was expecting. Why should all three arguments be promoted to cell strings in the first example, but in the third case only after the two strings are concatenated.. This seems like another case of an adhoc matlab implementation.

In fact I now have another case that might be problematic. What does matlab give for

['s1', {[1,1]}]
[{[1,1]}, 's1']

That is does the promotion of the strings only happen is the cell array contains strings, or does the promotion always happen?

D.

David Bateman <dbateman>
Project Member
Wed 18 May 2011 07:00:35 AM UTC, comment #6:

I will not speculate about what you expected this time:

>> version


ans =

7.9.0.529 (R2009b)

>> ['s1', 's2', {'s3'}]


ans =

's1' 's2' 's3'

>> ['s1'; 's2'; {'s3'}]


ans =

's1'
's2'
's3'

>> ['s1', 's2'; {'s3'}]


ans =

's1s2'
's3'

>>

Michael Godfrey <godfrey>
Wed 18 May 2011 06:52:38 AM UTC, comment #5:

Ok its a little harder than I thought because we have to promote the strings to cell strings before checking the dimensions in the concatenation. However this raises another question of how matlab handles these cases

['s1', 's2', {'s3'}]
['s1'; 's2'; {'s3'}]
['s1', 's2'; {'s3'}]

D.

David Bateman <dbateman>
Project Member
Wed 18 May 2011 03:42:42 AM UTC, comment #4:

Okay, it does promote to cell string. I'm used to the Octave output which displays '{'/'}' around the answer when the type is of class cell.

Rik <rik5>
Project Administrator
Wed 18 May 2011 03:24:39 AM UTC, comment #3:

Apparently not: (same Matlab)

>> s = {'s1'};
>> s = [s; 's2'; 's3']


s =

's1'
's2'
's3'

>> sx = ['sx']


sx =

sx

>> whos

Name Size Bytes Class Attributes

s 3x1 348 cell
sx 1x2 4 char

>> sy = s(2)


sy =

's2'

>> whos

Name Size Bytes Class Attributes

s 3x1 348 cell
sx 1x2 4 char
sy 1x1 116 cell

>>

=================================
This seems a bit odd. Does it help?

Michael Godfrey <godfrey>
Tue 17 May 2011 11:30:27 PM UTC, comment #2:

Doesn't the test indicate the reverse? That the cellstr was demoted to an ordinary string and returned in a char array along with the other two strings.

Rik <rik5>
Project Administrator
Tue 17 May 2011 09:30:38 PM UTC, comment #1:

As you guessed, Matlab says:

>> version


ans =

7.9.0.529 (R2009b)

>> s = {'s1'};
>> s = [s; 's2'; 's3']


s =

's1'
's2'
's3'

>>

Michael Godfrey <godfrey>
Tue 17 May 2011 08:30:04 PM UTC, original submission:

While porting some code I ran across the following construct

Octave fails for the above. I no longer have access to matlab and can't easily check that matlab in fact supports the above. But the use of this code in the package I'm porting seems to imply that matlab promotes the strings to cell strings. So if someone could check the above and send the result it would be great.

The fix is relatively trivial with the addition of two concatenation methods in op-cell.cc

D.

David Bateman <dbateman>
Project Member

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

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 godfrey (Posted a comment)
  • -unavailable- added by dbateman (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 22 Jun 2013 02:07:47 AM UTCrik5Item GroupIncorrect Result=>Matlab Compatibility
      StatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup