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

 
 

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

Submitter:  Damian Only <damianonly>
Submitted:  Thu 03 Jul 2014 12:29:42 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.8.1 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 22 Dec 2015 05:52:35 PM UTC, comment #1: 

This is now fixed in the inputParser class which is a standard part of Octave 4.0.0.

Mike Miller <mtmiller>
Group Member
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 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 mtmiller (Posted a comment)
  • -email is unavailable- added by bpabbott (Updated the item)
  • -email is unavailable- added by damianonly (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-22 mtmiller StatusNone Fixed
        Open/ClosedOpen Closed
    2014-07-03 bpabbott CategoryLibraries Octave Package

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code