bugGNU Octave - Bugs: bug #45837, inputParser: checks property...

 
 

bug #45837: inputParser: checks property default value but should not

Submitted by:  Avinoam Kalma <avinoam>
Submitted on:  Thu 27 Aug 2015 03:41:17 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: AvinoamOpen/Closed: Closed
Release: 4.0.0Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Thu 08 Oct 2015 07:16:08 PM UTC, comment #6:

Finally fixed with http://hg.savannah.gnu.org/hgweb/octave/rev/a61f0d6beb71

Carnë Draug <carandraug>
Project Member
Mon 31 Aug 2015 02:55:27 PM UTC, comment #5:

It is bad programming what ML does, but I do not care. I think is better to follow their behavior, so that ML code works in Octave.

Would you do it or shall I do it?

Juan Pablo Carbajal <juanpi>
Project Member
Mon 31 Aug 2015 02:50:28 PM UTC, comment #4:

So apparently the issue is that Matlab does not checks if the default value passed to inputParser is valid or not. This is done by the validate_default method

http://hg.savannah.gnu.org/hgweb/octave/file/784ed55fdde8/scripts/general/inputParser.m#l438

and fixing it would be as simple as removing it. There is some performance to be gained by not running this test everytime if we want to go that way.

Carnë Draug <carandraug>
Project Member
Mon 31 Aug 2015 09:16:33 AM UTC, comment #3:

Therefore, if when the function ip_bug is called without arguments, the validator

p.addParamValue ('Dir', def_dir, @ischar);

gets and empty array (your default value) and it fails. This is consistent and correct, since as you just saw [] is double not char.

Now, it might be that Matlab's inputParser is not calling the validator when the default argument is given. I would deem that as a ML bug. Because it allows for default initializations that cannot be passed as input arguments.

The solution is to use consistent defautl values. in your case def_dir should pass the validation step, therefore it should be

+varbatim+
def_dir =""
-verbatim-

or if you think that is ambiguous

Juan Pablo Carbajal <juanpi>
Project Member
Mon 31 Aug 2015 03:52:09 AM UTC, comment #2:

Using Matlab 2010b

same results as Octave.

Avinoam Kalma <avinoam>
Project Member
Thu 27 Aug 2015 03:54:43 PM UTC, comment #1:

I octave the empty array is not of char type. Could you test the following in Matlab

In your function you could use def_dir = "" to make it work and be more conssistent.

Juan Pablo Carbajal <juanpi>
Project Member
Thu 27 Aug 2015 03:41:17 PM UTC, original submission:

Using the following function

in matlab R2010b

in Octave:

Avinoam Kalma <avinoam>
Project Member

 

(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 juanpi (Posted a comment)
  • -unavailable- added by avinoam (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 08 Oct 2015 07:16:08 PM UTCcarandraugStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Mon 31 Aug 2015 02:50:28 PM UTCcarandraugSummaryinputParser.addParamValue: failed validation for empty string=>inputParser: checks property default value but should not

    Back to the top


    Powered by Savane 3.1-cleanup1