bugGNU Octave - Bugs: bug #33536, strread returns incorect results...

 
 

bug #33536: strread returns incorect results and is not compatibile with Matlab

Submitted by:  Arnaud Delorme <arnodelorme>
Submitted on:  Sat 11 Jun 2011 03:40:55 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 3.4.0Operating System: Mac OS

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)

Wed 27 Jul 2011 02:06:13 PM UTC, comment #6:

This has been fixed on the development branch as of this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/f5a3f77d51aa). The reporter will need to build from the Mercurial sources in order to see the fix or wait until the next major release (3.6).

Rik <rik5>
Project Administrator
Fri 22 Jul 2011 10:29:21 PM UTC, comment #5:

Yes I overlooked the literal "[" before "%s", sorry.

Precisely this situation (reading just one line of text) exposes a weakness of the way I split leading literals from fields.
I have an alternative but at the time chose to not implement it as that one might break in case of e.g., empty numeric fields next to a literal.

The underlying issue is the way Octave's strread finally reads files (after internal preparation): columnwise, while ML probably does it line by line (and AFAIU with binary code).
Octave's way is fast for an m-file but makes for lots of interesting gotchas if we want to mimic all of ML's options.

I'll have a look - I need this fixed myself as well.

Philip Nienhuis <philipnienhuis>
Project Member
Fri 22 Jul 2011 08:26:40 PM UTC, comment #4:

This is almost resolved. The second of the two cases is fixed by Philip's changeset.

The first example is still a problem.

The current test in Octave is

This is not quite the same thing because the format specifier should be '[%s' to exactly reproduce the bug in question.

Philip, could you take a look at this?

Rik <rik5>
Project Administrator
Sun 12 Jun 2011 09:06:29 PM UTC, comment #3:

I almost have a fix ready, but I first need to test at work with the files that gave rise to bug # 32720 (hopefully next week I'll have an opportunity to do that).

The issue is closely related to entangled whitespace and delimiter processing. Whitespace processing (i.e. user-supplied) was absent in strread-as-is and (largely) fixed in bug #32720 (but the fix was not applied yet).

Would it be OK to close bug # 32720 and supply combined patches for #32720 and this bug (#33536)? (for both strread.m and textread.m)
In hindsight the patches I sent for 32720 could have been a bit better anyway :-)

Philip Nienhuis <philipnienhuis>
Project Member
Sun 12 Jun 2011 07:33:52 PM UTC, comment #2:

I've noticed lately that people use the word "crash" when they really mean "fails with an error". I don't know why this usage has come about, but it seems to be growing more common.

John W. Eaton <jwe>
Project Administrator
Sat 11 Jun 2011 10:19:02 PM UTC, comment #1:

Sorry for being picky, but:
What exactly do you mean by "crash"? (I suppose that strread bails out rather than that Octave crashes.)

A while ago I've sent in patches for textread & strread, a.o. for better ML compatibility (mainly whitespace processing; see bug #32720).

With these patches, in your:
- Case 1: strread ends normally but gives 's]' as result => still wrong (Note there's a stray '[' in your example).
- Case 2: Still fails.

I'll look into this, hopefully next week.
I'm in a similar situation as you (porting loads of ML code to Octave) and I found textread/strread/textscan do need some attention...
I might have a go at bugs #31380 and #31778 as well.

The test stanzas in strread.m were in need of some polishing anyway; the "cases" you brought forward seem like good candidates for better test cases.

Philip Nienhuis <philipnienhuis>
Project Member
Sat 11 Jun 2011 03:40:55 PM UTC, original submission:

strread function has multiple issues including returning different results compared to Matlab 

str = '[Common Infos]'; 
strread(str, '[%s', 'delimiter', ']') 

ans = 
'Common Infos' % 
(crashes under Octave)

[a,b,c] = strread('1,,2', '%s%s%s', 'delimiter', ',') 

(does not return the same result under Octave; under Matlab, the second element of the cell array is empty (as it should be) whereas under Octave the third one is empty)

Arnaud Delorme <arnodelorme>

 

(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 rik5 (Posted a comment)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by philipnienhuis (Posted a comment)
  • -unavailable- added by arnodelorme (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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 27 Jul 2011 02:06:13 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1