bugGNU Octave - Bugs: bug #56869, matlab incompatibility - input...

 
 

bug #56869: matlab incompatibility - input format specifiers %E and %G produce errors

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Sat 07 Sep 2019 08:36:36 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Nicholas Jankowski Open/Closed:  * Closed
Release:  * 5.1.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 10 Sep 2019 11:03:22 PM UTC, comment #7: 

I pushed a similar follow-up for the '%X' input specifier also supported by Matlab as an alias for '%x' (and had already been documented in the Octave user manual for a long time).

Mike Miller <mtmiller>
Group Member
Tue 10 Sep 2019 03:27:46 PM UTC, comment #6: 

I confirmed that the patch from comment #4 now makes scanf behave the same with %e and %E, as well as %g and %G:


>> sscanf ("345678e-12", "%e")
ans =  0.00000034568
>> sscanf ("345678E-12", "%e")
ans =  0.00000034568
>> sscanf ("345678e-12", "%E")
ans =  0.00000034568
>> sscanf ("345678E-12", "%E")
ans =  0.00000034568
>> sscanf ("345678e-12", "%g")
ans =  0.00000034568
>> sscanf ("345678e-12", "%G")
ans =  0.00000034568


Closing report as fixed

Pantxo Diribarne <pantxo>
Group Member
Tue 10 Sep 2019 01:11:03 AM UTC, comment #5: 

Ok, will edit the patch to bug #56557 to put the %E %G back in the doc

Nicholas Jankowski <nrjank>
Group Member
Mon 09 Sep 2019 11:01:42 PM UTC, comment #4: 

Thanks for the info.  I pushed the following changeset on default:

http://hg.savannah.gnu.org/hgweb/octave/rev/9354d33dfbc4

John W. Eaton <jwe>
Group administrator
Mon 09 Sep 2019 10:32:28 PM UTC, comment #3: 


> Is Matlab always ignoring case?


No, it is only supporting these specific uppercase format specifiers which are valid output specifiers, and also allowing them as input specifiers. Other uppercase letters that are not valid output specifiers are not allowed.

These


y = sscanf ('10', '%C')
y = sscanf ('10', '%D')
y = sscanf ('10', '%F')
y = sscanf ('10', '%I')
y = sscanf ('10', '%O')
y = sscanf ('10', '%S')
y = sscanf ('10', '%P')
y = sscanf ('10', '%U')


all return an empty char array (not an error, like Octave does).

And '%L' is not a valid width modifier in Matlab sscanf, it is not a synonym for lowercase '%l'.

Mike Miller <mtmiller>
Group Member
Mon 09 Sep 2019 10:24:07 PM UTC, comment #2: 

Did you check other input format specifiers?  Is Matlab always ignoring case?  What about the other input format specifiers, d, i, o, u, f, c, s, and p?  I don't see that Matlab has p, and maybe we shouldn't either...

And what about the length specifiers h and l?  I don't see that Matlab has h, but it have l.  And we already have both l and L, so if Matlab treats l and L the same, I'm not sure what to do for that one.

John W. Eaton <jwe>
Group administrator
Mon 09 Sep 2019 09:47:24 PM UTC, comment #1: 

I agree, this is undocumented and probably not necessary, but it's a relatively easy change to make and maintain, we might as well do it.

Should we also support '%X' as an alias for '%x'? Matlab seems to allow that one as well.

Mike Miller <mtmiller>
Group Member
Sat 07 Sep 2019 08:36:36 PM UTC, original submission:  

Referring to bug #56557 - in discussing Formatted Input documentation, was notd that specifiers %E and %G (in caps) aren't valid in Octave.  Documentation patch removes reference to %E and %G. 

Was noted that in Matlab 2019a, %E and %G are treated the same as %e and %g, wheras in Octave it produces an "error: sscanf: invalid format specified"

The Octave documentation dating back to 1996 indicated that %E and %G were supposed to operate just like %e and %g. This was thought to maybe have been unintentional copying from the Formatted Output sections, but given that it was around so long and is the same behavior as in Matlab, perhaps it was the original intention.

Alternatively, it should be noted that the current Matlab help for sscanf, fscanf, etc., make no mention of %E and %G, but do for formatted input sections. And we generally don't do undocumented compatibility.

Recommending that this be added as a low priority compatibility bug since it seems like it should be a minor alias to have %E/G perform the same as %e/g.  Wolud also need to remember to add the specifier text back in on the 'Table of Input Conversions' page.

Nicholas Jankowski <nrjank>
Group Member

 

(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 pantxo (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by nrjank (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-09-10 pantxo StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-09-09 jwe StatusConfirmed Ready For Test
    2019-09-09 mtmiller StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code