help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave inputParser


From: Carnë Draug
Subject: Re: Octave inputParser
Date: Thu, 10 May 2012 20:01:48 +0100

On 20 April 2012 14:27, Carnë Draug <address@hidden> wrote:
> On 20 April 2012 12:22, Aki Vehtari <address@hidden> wrote:
>> Hi,
>>
>>> How does it succeed in Matlab? This does not make sense. How can you
>>> skip the optional parameters and jump into param/value? How can one
>>> know if it's an optional parameter that does not validate or the key
>>> for a parameter?
>>
>>
>> If optional input is not a string it can not be a parameter name and there
>> is no possibility of confusion. If optional input can be a string, then
>> Matlab documentation says
>> http://www.mathworks.se/help/techdoc/matlab_prog/bresuxt-11.html
>> "If your function accepts optional input strings and parameter name and
>> value pairs, specify validation functions for the optional input strings.
>> Otherwise, the Input Parser interprets the optional strings as parameter
>> names. For example, the checkFinish validation function ensures that
>> printPhoto interprets 'glossy' as a value for finish and not as an invalid
>> parameter name."
>>
>> Thus it is possible to leave out optional arguments even when using
>> ParamValue arguments, too.
>
> Oh, I see. I missed that part of the documentation. Looks ugly but
> yeah, it's a matlab compatibility bug. Can you submit a patch for
> this? My guess is that in subsref.m, in the loop that checks the
> optional arguments, if the value does not validate, check if it's a
> string and if so, break the loop. I won't have time to do it in the
> next 1-2 weeks. If you have some code for testing, something that you
> know it works in matlab, would be great. If you submit that code to
> me, I can make them a test block at the end of the file (they are the
> %! that some functions have at the end). All I can do is try to fix it
> based on what it's written on their site and hope for the best (and as
> you can see, my interpretation is not always the right)

Hi

I finally got around this and kind of fixed it on the development
version (together with some other problems). Now if an argument is a
string and does not validate against whatever was given as Optional,
it will be considered to be a key for a ParamValue or Switch argument.
However, unlike matlab, I'm still considering that if no validator is
given, it still counts as valid Optional value. You may want to
checkout the SVN tree. I have also added some test blocks to prevent
future problems. Any feedback would be great (specially patches) as
I'd like to make a new release of the package.

Carnë


reply via email to

[Prev in Thread] Current Thread [Next in Thread]