octave-maintainers
[Top][All Lists]
Advanced

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

Re: Implementing categorial function


From: Mike Miller
Subject: Re: Implementing categorial function
Date: Sat, 26 Nov 2016 10:27:00 -0800
User-agent: NeoMutt/20161104 (1.7.1)

On Sat, Nov 26, 2016 at 06:54:10 -0800, NVS Abhilash wrote:
> I wanted to ask is it okay to use inputParser in my class constructor or
> not. Because I tried doing it and I am getting some silly error. Please tell
> me weather their is mistake in my code or in inputParser.

You can certainly use inputParser, it's been included in Octave since
4.0. But keep in mind that inputParser is only useful for name-value
pairs of arguments, as in

  myfunc (1)
  myfunc (1, 2)
  myfunc (1, {"a", "b", "c"})
  myfunc (1, {"a", "b", "c"}, "something", true)

inputParser would only be useful for the "something" boolean optional
argument.

For categorical, it looks to me like inputParser would only help with
the "ordinal" and "protected" options.

For other positional arguments, it's usually sufficient to test nargin
and check the types of varargin{i} and handle them appropriately.

> The functions implemented are uploaded here: 
> https://address@hidden/nvs232/octave-categorical
> <https://address@hidden/nvs232/octave-categorical>  

That should be https://bitbucket.org/nvs232/octave-categorical for
anyone other than you.

> Also please have a overview of the work done yet, and suggest any better way
> of doing things, though it is not working now, but I tried doing it normally
> by nargin it worked fine for 3 arguments, but the constructor requires
> varargin. So is their a better way to implement this. 

It looks like a start. I would recommend that you get in the habit of
using Octave coding style right away.

 * use 2 spaces per indent level
 * use endfor instead of end
 * use " for strings and # for comments
 * use lowercase for your variable names and class / struct properties
 * use a space between a function name and the opening parenthesis

And absolutely essential is that every file must have a copyright and
license header. Since you want these functions to be included in Octave,
please use the GPLv3+. Every file in Octave has a header that you can
use as a template.

-- 
mike



reply via email to

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