bugGNU Octave - Bugs: bug #52420, inputParser optional argument is...

 
 

bug #52420: inputParser optional argument is "not a valid parameter"

Submitted by:  None
Submitted on:  Thu 16 Nov 2017 01:31:08 PM UTC  
 
Category: Octave FunctionSeverity: 2 - Minor
Priority: 3 - LowItem Group: Matlab Compatibility
Status: Wont FixAssigned to: None
Originator Name: Ryan GovostesOriginator Email: -unavailable-
Open/Closed: ClosedRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Fri 17 Nov 2017 02:04:37 AM UTC, comment #4:

Octave generally doesn't try to match undocumented Matlab behavior because it can change unpredictably between versions. I'm not sure why addOptional is working in Matlab, but since usin addParameter seems to be the correct thing to do, and it works, I'm going to close this report.

Rik <rik5>
Project Administrator
Fri 17 Nov 2017 01:35:17 AM UTC, comment #3:

I confirmed that the snippet works Matlab R2017a, but the documentation for Matlab's addOptional indicates that maybe Octave is correct here:

> Use addOptional to add an individual argument into the input parser scheme. If you want to parse an optional name-value pair, use the addParameter function.


I changed the code to use addParameter and it seems to be happier now.

Anonymous
Fri 17 Nov 2017 01:09:03 AM UTC, comment #2:

Can the original reporter test this code, as written, in Matlab? I'm not certain that it is valid. According to the documentation for addOptional (http://www.mathworks.com/help/matlab/ref/inputparser.addoptional.html), addOptional creates a positional input variable, not a key/value pair.

If you want to call with syntax of "name", value then you need to use addParameter. Making that change to foo allows the function to run correctly.

Rik <rik5>
Project Administrator
Fri 17 Nov 2017 12:52:16 AM UTC, comment #1:

Confirmed. Version 4.0.3 of Octave which you reported as using is deprecated and no longer supported. However, I can reproduce this bug on the latest development code as well.

Thanks for taking the time to report this bug.

Without a stack trace from the crash it's very hard to determine
what caused it. Can you get us a stack trace? Please see
http://wiki.octave.org/Debugging_Octave for more information on
how to do so. Thanks in advance!

Rik <rik5>
Project Administrator
Thu 16 Nov 2017 01:31:08 PM UTC, original submission:

I'm running some code originally written for MATLAB which uses an inputParser to parse arguments. Here's a reduced example:

When I invoke this, I get an unexpected error:

I'm not very familiar with MATLAB but the documentation for function input parsing seems to suggest that this code is correct and that Octave's behavior deviates from MATLAB's.

Anonymous

 

(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 rik5 (Posted a comment)
  • -unavailable- added by None (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 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 17 Nov 2017 02:04:37 AM UTCrik5Severity3 - Normal=>2 - Minor
      Priority5 - Normal=>3 - Low
      StatusNeed Info=>Wont Fix
      Open/ClosedOpen=>Closed
    Fri 17 Nov 2017 01:09:03 AM UTCrik5StatusConfirmed=>Need Info
    Fri 17 Nov 2017 12:52:16 AM UTCrik5StatusNone=>Confirmed
      Release4.0.3=>dev
      Operating SystemMac OS=>Any

    Back to the top


    Powered by Savane 3.1-cleanup1