[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #49793] octave's inputParser only accepts vali
From: |
Georg Wiora |
Subject: |
[Octave-bug-tracker] [bug #49793] octave's inputParser only accepts validation functions that return true or false |
Date: |
Fri, 20 Oct 2017 08:50:43 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0 |
Follow-up Comment #10, bug #49793 (project octave):
I stumbled on the same problem as described in this bug when using the
function dirPlus.m from Matlabs FileExchange. There the function
validateattributes() was used for argument checking in input parsers. This
function has no return value and does throw an error if argument checking
fails. In matlab it seems to be valid to do so.
I have created a fix for inputParser in octave to handle this type of
functions that does also print a bit more verbose information on what has been
checked if the check fails.
See my fix for inputParser.m line ~500 below.
function validate_arg (this, name, val, in)
% Check validation result to be empty in case of the use of
validateattributes function
% An empty result will be interpreted as valid arguments
check = {val(in)};
if (~isempty(check) && ~val(in))
this.error (sprintf ("failed validation of %s with %s", toupper
(name),func2str(val)));
endif
this.Results.(name) = in;
endfunction
Take care: in the original source "val (in)" was written with a blank. This
leads to a different result in this statement. It must be written *without
blank* as "val(in)"!
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?49793>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #49793] octave's inputParser only accepts validation functions that return true or false,
Georg Wiora <=