bugGNU Octave - Bugs: bug #42670, Input parser: dependence on the...

 
 

bug #42670: Input parser: dependence on the order of the arguments

Submitted by:  Damian Only <damianonly>
Submitted on:  Thu 03 Jul 2014 12:29:42 PM UTC  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: NoneAssigned to: None
Originator Name: Open/Closed: Open
Release: 3.8.1Operating 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.

 

Thu 03 Jul 2014 12:29:42 PM UTC, original submission:

parameter parsing depends on the order of the arguments. Thefollowing code snippet illustrates this:

varargin = {'pval0', 0, 'pval1', 1, 'pval2', 2};

varargin1 = {'pval0', 0, 'pval2', 2, 'pval1', 1};

p = inputParser;
p.CaseSensitive = true;
p.KeepUnmatched = true;
p = p.addParamValue('pval0', 0, @isnumeric);
p = p.addParamValue('pval2', 0, @isnumeric);

res = p.parse(varargin{:})

res = p.parse(varargin1{:})

In the first case, only 'pval0' will appear in the 'Results' field of 'res'. However, if the order in which the arguments are passed is swapped, then both 'pval0' and 'pval1' are stored in 'Results'. The latter is the behavior I'd expect.

In Matlab the last two lines in the snippet above yield the same results.

Damian Only <damianonly>

 

(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 bpabbott (Updated the item)
  • -unavailable- added by damianonly (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):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 03 Jul 2014 02:08:18 PM UTCbpabbottCategoryLibraries=>Octave Forge Package

    Back to the top


    Powered by Savane 3.1-cleanup