Problem with inputParser and anonymous functions for validators

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with inputParser and anonymous functions for validators

Jose
Hello.

I am trying to use inputParser and anonymous functions for validators. I
get errors, as follows.

octave:2> p = inputParser;
octave:3> val = @(x) ischar(x);
octave:4> val('hello')
ans =  1
octave:5> p = addRequired (p,"pack", @val);
error: @val: no function and no method found
error: evaluating argument list element number 3
octave:5> p = addRequired (p,"pack", @ischar);


Any hints?
I am using octave 3.6.2 and general package 1.3.2

BR
Jose
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Problem with inputParser and anonymous functions for validators

bpabbott
Administrator
On Sep 21, 2012, at 2:12 PM, Jose wrote:

> Hello.
>
> I am trying to use inputParser and anonymous functions for validators. I get errors, as follows.
>
> octave:2> p = inputParser;
> octave:3> val = @(x) ischar(x);
> octave:4> val('hello')
> ans =  1
> octave:5> p = addRequired (p,"pack", @val);
> error: @val: no function and no method found
> error: evaluating argument list element number 3
> octave:5> p = addRequired (p,"pack", @ischar);
>
>
> Any hints?
> I am using octave 3.6.2 and general package 1.3.2
>
> BR
> Jose

@char is a function handle for the function char(). "val" is the function handle @(x)ischar(x).  @val is invalid syntax.

What you need to do is either

(1) addRequired (p, "pack", val)

or

(2) addRequired (p, "pack", @(x)ischar(x))

or

(3) addRequired (p, "pack", @ischar)

Ben


_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Problem with inputParser and anonymous functions for validators

bpabbott
Administrator
On Sep 21, 2012, at 2:59 PM, Jose wrote:

> Hello.
>
> On 09/21/2012 09:33 PM, Ben Abbott wrote:
>
>> What you need to do is either
>>
>> (1) addRequired (p, "pack", val)
>>
>> or
>>
>> (2) addRequired (p, "pack", @(x)ischar(x))
>>
>> or
>>
>> (3) addRequired (p, "pack", @ischar)
>
> Thanks Ben. It works.
>
> It seems then that the documentation is not correct (See the example in "help inputParser" and
> http://octave.sourceforge.net/general/function/@inputParser/inputParser.html ).
>
> BR
> Jose
>

I think you are correct. There appears to be a problem with the documentation.  I've cc'd the author.


Ben

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Problem with inputParser and anonymous functions for validators

Juan Pablo Carbajal
On Fri, Sep 21, 2012 at 10:09 PM, Ben Abbott <[hidden email]> wrote:

> On Sep 21, 2012, at 2:59 PM, Jose wrote:
>
>> Hello.
>>
>> On 09/21/2012 09:33 PM, Ben Abbott wrote:
>>
>>> What you need to do is either
>>>
>>> (1) addRequired (p, "pack", val)
>>>
>>> or
>>>
>>> (2) addRequired (p, "pack", @(x)ischar(x))
>>>
>>> or
>>>
>>> (3) addRequired (p, "pack", @ischar)
>>
>> Thanks Ben. It works.
>>
>> It seems then that the documentation is not correct (See the example in "help inputParser" and
>> http://octave.sourceforge.net/general/function/@inputParser/inputParser.html ).
>>
>> BR
>> Jose
>>
>
> I think you are correct. There appears to be a problem with the documentation.  I've cc'd the author.
>
>
> Ben
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

Problem fixed.

Thank you for reporting it! :D

@Jose: You know you can edit the help of these functions yourself? Let
me know if you do not know and need some help to ge the hands on it.
If we do this, then you can send us the respective correction. In that
way you will be helping GNU Octave to get better!
At the same time you will getting the hands of how to write
documentation and functions for Octave, with some luck we will have
you(!) among the usual contributors in no time.

Cheers


--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Problem with inputParser and anonymous functions for validators

Jose
On 09/22/2012 11:44 AM, Juan Pablo Carbajal wrote:
>
> @Jose: You know you can edit the help of these functions yourself? Let
> me know if you do not know and need some help to ge the hands on it.

Let's say that I have an intuition about how to do it, but no "official"
instructions (which I'd like to have, yes).

> If we do this, then you can send us the respective correction. In that
> way you will be helping GNU Octave to get better!
> At the same time you will getting the hands of how to write
> documentation and functions for Octave, with some luck we will have
> you(!) among the usual contributors in no time.

Even better than explaining me, it would be nice to write it down in a
wiki or alike, so it can be used as a reference to others ;). And if
that is available already, please point me to the right place so that I
can read it :). Sometimes finding things about octave in the web pages
is really tricky ;).

BR
Jose



_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Problem with inputParser and anonymous functions for validators

Juan Pablo Carbajal
On Sat, Sep 22, 2012 at 11:30 AM, Jose <[hidden email]> wrote:

> On 09/22/2012 11:44 AM, Juan Pablo Carbajal wrote:
>>
>>
>> @Jose: You know you can edit the help of these functions yourself? Let
>> me know if you do not know and need some help to ge the hands on it.
>
>
> Let's say that I have an intuition about how to do it, but no "official"
> instructions (which I'd like to have, yes).
>
>
>> If we do this, then you can send us the respective correction. In that
>> way you will be helping GNU Octave to get better!
>> At the same time you will getting the hands of how to write
>> documentation and functions for Octave, with some luck we will have
>> you(!) among the usual contributors in no time.
>
>
> Even better than explaining me, it would be nice to write it down in a wiki
> or alike, so it can be used as a reference to others ;). And if that is
> available already, please point me to the right place so that I can read it
> :). Sometimes finding things about octave in the web pages is really tricky
> ;).
>
> BR
> Jose
>
>
>

Hi Jose,

Ok, if the help here helps than I will transcribe it to the wiki...
though you could also do it! ;)

== One shot contribution ==
- All forge packages (name will change as soon we have Agora online
running) are hosted here
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/
You can look for the package in question, get the latest version that
could be unreleased (that is, it is not yet listed in the OctaveForge
website anmd you will not ge tit by doing >pkg -forge install
my-package). You can use this function if you copy on top of the old
one (or rename the old one to *_old.m), but be careful because it may
require other new functions. Anyway, you can get the latest and
coolest version of any package from that site.
- Once you have the newest version of the function, check if it still
has the bug you found. If it doesn't somebody solved it already. If
the problem still there go on an fix it!
- Once you have fixed the bug, you can send a patch with your changes.
How do you this? Start another thread or read the relevant parts of
the documentation of "diff" and
"patch"(http://www.gnu.org/software/diffutils/manual/diffutils.html).

=== Another way ===
You can also checkout the package in question using svn. For example
if you wan to checkout the general package you would run
> svn co https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/main general general_to_debug

This will create a folder "general_to_debug" in your current
directory. You can hack away as much as you can and then produce the
patch and send it to the mailing list.

=== New files or buch of files ===
There is a third way of contributing to Octave.Lets say you do not
want to be a developer but you have one or a bunch of functions you
want to share with us. You can use the Features request forum (this
willbe also replaced by Agora when it is up and running)
https://sourceforge.net/tracker/?group_id=2888&atid=352888
Upload your file (compressed if it is more than one) and lets us know
that you did it by sending a mail to the mailing list. If there is
anybody interested they will look at your code and give you
suggestions. Speed up that process by adding a GPL compatible license
(http://en.wikipedia.org/wiki/List_of_FSF-approved_software_licenses)

== Being a Forger ==
If you want to be one of us, you can also request to be a Forge
developer (name may change) following the instructions here
http://octave.sourceforge.net/developers.html

Let us know if there are more questions

Looking forward for your next contribution

--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Problem with inputParser and anonymous functions for validators

Jose
On 09/22/2012 03:51 PM, Juan Pablo Carbajal wrote:
> Hi Jose,
>
> Ok, if the help here helps than I will transcribe it to the wiki...
> though you could also do it! ;)

Hello Juan Pablo.

Thanks for the explanations, octave has one less secret for me now ;).

About putting this to the wiki, I definitely think that this should be
easily accessible, so I would put it in the wiki. In general I think
that having instructions on the wiki for people that want to cooperate
is good.

Please, write them yourself there. What I can do is, once that I follow
your instructions (from the wiki), I will complete them (if necessary)
with detailed commands or comments that helped me as a new collaborator :)

BR
Jose

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Problem with inputParser and anonymous functions for validators

Juan Pablo Carbajal
On Wed, Sep 26, 2012 at 3:13 PM, Jose <[hidden email]> wrote:

> On 09/22/2012 03:51 PM, Juan Pablo Carbajal wrote:
>> Hi Jose,
>>
>> Ok, if the help here helps than I will transcribe it to the wiki...
>> though you could also do it! ;)
>
> Hello Juan Pablo.
>
> Thanks for the explanations, octave has one less secret for me now ;).
>
> About putting this to the wiki, I definitely think that this should be
> easily accessible, so I would put it in the wiki. In general I think
> that having instructions on the wiki for people that want to cooperate
> is good.
>
> Please, write them yourself there. What I can do is, once that I follow
> your instructions (from the wiki), I will complete them (if necessary)
> with detailed commands or comments that helped me as a new collaborator :)
>
> BR
> Jose
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Octave-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/octave-dev

Sounds great!
I will do that asap.


--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Problem with inputParser and anonymous functions for validators

Juan Pablo Carbajal
On Wed, Sep 26, 2012 at 6:48 PM, Juan Pablo Carbajal
<[hidden email]> wrote:

> On Wed, Sep 26, 2012 at 3:13 PM, Jose <[hidden email]> wrote:
>> On 09/22/2012 03:51 PM, Juan Pablo Carbajal wrote:
>>> Hi Jose,
>>>
>>> Ok, if the help here helps than I will transcribe it to the wiki...
>>> though you could also do it! ;)
>>
>> Hello Juan Pablo.
>>
>> Thanks for the explanations, octave has one less secret for me now ;).
>>
>> About putting this to the wiki, I definitely think that this should be
>> easily accessible, so I would put it in the wiki. In general I think
>> that having instructions on the wiki for people that want to cooperate
>> is good.
>>
>> Please, write them yourself there. What I can do is, once that I follow
>> your instructions (from the wiki), I will complete them (if necessary)
>> with detailed commands or comments that helped me as a new collaborator :)
>>
>> BR
>> Jose
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Octave-dev mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/octave-dev
>
> Sounds great!
> I will do that asap.
>
>
> --
> M. Sc. Juan Pablo Carbajal
> -----
> PhD Student
> University of Zürich
> http://ailab.ifi.uzh.ch/carbajal/

Ok, I created this page
http://wiki.octave.org/Contributing_to_the_development_of_packages/modules

improve it!
:D


--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave