octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #49793] octave's inputParser only accepts vali


From: anonymous
Subject: [Octave-bug-tracker] [bug #49793] octave's inputParser only accepts validation functions that return true or false
Date: Wed, 7 Dec 2016 13:46:52 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0

URL:
  <http://savannah.gnu.org/bugs/?49793>

                 Summary: octave's inputParser only accepts validation
functions that return true or false
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Wed 07 Dec 2016 01:46:50 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.2.0
        Operating System: GNU/Linux

    _______________________________________________________

Details:



ip = inputParser;
htest = @(h) validateattributes(h, {'double'}, {'nonnegative'});
ip.addRequired('h', htest);
ip.parse(1.0);


fails with


error: if: undefined value used in conditional expression
error: called from
    validate_arg at line 505 column 9
    parse at line 394 column 9


>From Matlab's documentation (cf.
https://de.mathworks.com/help/matlab/ref/inputparser.addrequired.html):
"inputParser accepts two types of validation functions: functions that return
true or false, and functions that pass or throw an error. Both types of
validation functions must accept a single input argument."


octave/4.2.0/m/general/inputParser.m lines 504 to 509:

    function validate_arg (this, name, val, in)
        if (! val (in))    % <- octave throws here the error
          this.error (sprintf ("failed validation of %s", toupper (name)));
        endif
        this.Results.(name) = in;
    endfunction


Octave's function validate_arg which is called from Octave's inputParser's
parse function can handle only validation functions that return true or
false.
It has to be rewritten, to cope with validation functions that return nothing
or throw and error, as validateattributes does, to be MATLAB compatible.





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?49793>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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