bugGNU Octave - Bugs: bug #50752, inputParser Parameter key are...

 
 

bug #50752: inputParser Parameter key are parsed as Optional

Submitted by:  John W. Eaton <jwe>
Submitted on:  Fri 07 Apr 2017 04:19:09 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: jweOpen/Closed: Closed
Release: devOperating System: Any

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 10 Apr 2017 02:45:53 PM UTC, comment #8:

I got someone to test those so I pushed the following tests

http://hg.savannah.gnu.org/hgweb/octave/rev/5a3c3ff03167

Carnë Draug <carandraug>
Project Member
Mon 10 Apr 2017 02:10:30 PM UTC, comment #7:

This error message is just wrong. It looks like a Matlab bug so I don't think we will replicate it:

Can you run one last test, please:

Carnë Draug <carandraug>
Project Member
Sun 09 Apr 2017 08:31:59 PM UTC, comment #6:

Here the output for the 3 snippets:

A.R. Burgers <arb>
Sun 09 Apr 2017 04:54:31 PM UTC, comment #5:

Well, Matlab compatibility seems to make it impossible to have
positional options whose value is a parameter key. I pushed this
change which adds those tests and also works for Switch options:

http://hg.savannah.gnu.org/hgweb/octave/rev/f1bf2590272a

Can someone with Matlab tell us how it behaves in the following cases?

+verbatim-+
%% Does this errors about missing value for parameter line?
p = inputParser ();
p.addOptional ('op1', 'val1');
p.addParameter ('line', 'circle');
p.parse ('line');
p.Results ()
-verbatim-

Carnë Draug <carandraug>
Project Member
Sat 08 Apr 2017 08:33:13 AM UTC, comment #4:

I get this:

A.R. Burgers <arb>
Fri 07 Apr 2017 06:38:59 PM UTC, comment #3:

Based on the comment for the test, I assumed that Matlab behaved as the test expected. For your example, that would mean setting line to "circle" and op1 and op2 to their default values. Could someone test this in Matlab?

John W. Eaton <jwe>
Project Administrator
Fri 07 Apr 2017 05:53:34 PM UTC, comment #2:

> It seems reasonable to me to stop processing optional parameters as soon as a name/value pair is recognized. Is there some reason not to do that?


The name of a parameter can also be a valid value for a positional option. Since positional options must come first, if a value is a valid positional option, then it should be treated as such instead as key/value pair. Consider this case:

Should op1 and op2 should be set to line and circle respectively, and line be set to the default value of tree? Or should op1 and op2 be set to their default values and line be set to circle?

I think the current behaviour is the most logical since positional options should be all be processed before trying to match key value parameters. But I guess we need to do whatever Matlab does. What does Matlab do?

Carnë Draug <carandraug>
Project Member
Fri 07 Apr 2017 04:25:52 PM UTC, comment #1:

I checked in the following changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/7b594fcfa32b

It seems reasonable to me to stop processing optional parameters as soon as a name/value pair is recognized. Is there some reason not to do that?

John W. Eaton <jwe>
Project Administrator
Fri 07 Apr 2017 04:19:09 PM UTC, original submission:

Creating this bug report so that the following test in inputParser.m can have a bug report number:

John W. Eaton <jwe>
Project Administrator

 

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

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 10 Apr 2017 02:45:53 PM UTCcarandraugStatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Fri 07 Apr 2017 05:53:34 PM UTCcarandraugSummarytest failure for inputParser=>inputParser Parameter key are parsed as Optional
    Fri 07 Apr 2017 04:25:52 PM UTCjweStatusNone=>Ready For Test

    Back to the top


    Powered by Savane 3.1-cleanup1