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

 
 

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

Submitter:  Arnaud Delorme <arnodelorme>
Submitted:  Sat 11 Jun 2011 03:40:55 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.4.0 Operating System:  * Mac OS
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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>
Group 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


%!test
%! # Bug #33536
%! a = strread ("[SomeText]", "%s", "delimiter", "]");
%! assert (a{1}, "[SomeText");


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

    Date Changed by Updated Field Previous Value => Replaced by
    2011-07-27 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code