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

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


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>
Project Administrator
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:

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)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project 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 Forge Package

    Back to the top

    Powered by Savane 3.3