patchGNU Octave - Patches: patch #9241, More verbose information when...

 
 

patch #9241: More verbose information when inputParser fails validating argument

Submitter:  Georg Wiora <gwiora>
Submitted:  Fri 27 Jan 2017 09:44:42 AM UTC
   
 
Category:  Core : new feature Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  siko1056 Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 08 Feb 2017 10:46:36 AM UTC, comment #5: 
Kai Torben Ohlhus <siko1056>
Group Member
Wed 08 Feb 2017 10:39:02 AM UTC, comment #4: 

Just for the files: The test script before the patch with less verbose information what to do:


>> p = inputParser();
>> p.addParameter('Para1',{},@ischar);
>> p.addParameter('Para2',[],@isnumeric);
>> p.parse('Para1','this is a valid argument for Para1','Para2',[1,2,3]);
>> p.parse('Para1',1);

error: failed validation of PARA1
error: called from
    error at line 539 column 7
    validate_arg at line 506 column 11
    parse at line 454 column 11

>> p.parse('Para2','abc');
error: failed validation of PARA2
error: called from
    error at line 539 column 7
    validate_arg at line 506 column 11
    parse at line 454 column 11


After the patch the last two statements with the same input:


>> p.parse('Para1',1);
error: failed validation of PARA1 with @(x) ischar (x)
error: called from
    error at line 541 column 7
    validate_arg at line 507 column 11
    parse at line 455 column 11

>> p.parse('Para2','abc');
error: failed validation of PARA2 with isnumeric
error: called from
    error at line 541 column 7
    validate_arg at line 507 column 11
    parse at line 455 column 11



Kai Torben Ohlhus <siko1056>
Group Member
Mon 06 Feb 2017 06:33:56 PM UTC, comment #3: 

I have problems downloading file #39682 and file #39683 from comment #2. Can you upload them again, or e-mail directly to -email is unavailable- ?

Kai Torben Ohlhus <siko1056>
Group Member
Mon 06 Feb 2017 04:18:34 PM UTC, comment #2: 

I have appended a test script and my modified version of the class.

If your run this with the modified inputparser you get the following results if executing line 17

error: parse error
>> error: failed validation of PARA2 with isnumeric"


And this result if you excute line 16:

error: parse error
>> error: failed validation of PARA1 with @(x) ischar (x)




(file #39682, file #39683)

Georg Wiora <gwiora>
Sat 04 Feb 2017 12:37:44 AM UTC, comment #1: 

Thank you for your suggestion. Can you provide a short example with input and output before and after your change? So I can assure, that the change I perform agrees with your expectations on it.

Kai Torben Ohlhus <siko1056>
Group Member
Fri 27 Jan 2017 09:44:42 AM UTC, original submission:  

inputParser class can easily print very helpful information if the validation function of a parsed argument fails.

Because validation functions very often are anonymous functions it is usefull to print the function body to give immediate information which check failed.

For that purpose line 506 in inputParser.m (octave 4.2.0) has to be replaced by

this.error (sprintf ("failed validation of %s with %s", toupper (name),func2str(val)));


I found this usefull.

Georg

Georg Wiora <gwiora>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #39682:  InputParser-Test.m added by gwiora (579B - application/octet-stream - Test script and modified inputParser.m class file.)
file #39683:  inputParser.m added by gwiora (26KiB - application/octet-stream - Test script and modified inputParser.m class file.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by gwiora (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-02-08 siko1056 StatusIn Progress Done
        Open/ClosedOpen Closed
    2017-02-08 siko1056 StatusNeed Info In Progress
        Assigned toNone siko1056
    2017-02-06 gwiora Attached File- Added InputParser-Test.m, #39682
        Attached File- Added inputParser.m, #39683
    2017-02-04 siko1056 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code