patchGNU Octave - Patches: patch #7649, new function narginchk

 
 

patch #7649: new function narginchk

Submitter:  Carnë Draug <carandraug>
Submitted:  Fri 28 Oct 2011 04:42:56 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  jordigh Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 10 Nov 2011 03:36:00 AM UTC, comment #4: 

Your new patch looked good to me. I pushed it:

http://hg.savannah.gnu.org/hgweb/octave/rev/e36817e2ee60

Jordi Gutiérrez Hermoso <jordigh>
Group Member
Sun 30 Oct 2011 09:32:20 PM UTC, comment #3: 

Hi!

just wondering. Is everything ok with the new patch?

Carnë Draug <carandraug>
Group Member
Fri 28 Oct 2011 05:28:51 PM UTC, comment #2: 

Sure. I think these are all the changes. The reason why I splitted evalin over several lines is just personal style. Same for the spaces around conditions on if blocks. I reformatted as requested.

For placement in the manual, I just grepped it for nargoutchk and placed on the same location.

(file #24234)

Carnë Draug <carandraug>
Group Member
Fri 28 Oct 2011 05:01:27 PM UTC, comment #1: 

You need to do a few more things to properly add a function to Octave.  The file must be listed in the appropriate scripts/*/module.mk file and a tag for the docstring should be added to some appropriate place in one of the manual's .txi source files.

I don't think @seealso should refer to functions that we don't have, so please remove inputParser from the list.

Doc strings should start with a statement that is like a command, so "Check for ...", not "Checks for ..."

"hev" in the docstring should be "have"?

Why do you split the evalin call across multiple lines?

To be consistent with the rest of Octave, please use double quotes for character strings unless there is a specific need to use single quotes.

There is no need to put your email address in the Copyright line, but if you would like to add an "## Author: " line, after the docstring and just before the function line, it can go there.  See other functions for an example.

Please don't put spaces after "(" or before ")".  So write


if (nargin != 2)


not


if ( nargin != 2 )


Could you please update your changeset and attach it again?

Thanks.

John W. Eaton <jwe>
Group administrator
Fri 28 Oct 2011 04:42:56 PM UTC, original submission:  

Hi

I'm submitting a new function to octave which has been added to matlab in the version 2011b (I asked in ##matlab and seems it's not present in 2011a).

It's a ridiculously simple thing but if someone codes is ever dependent on it, it's already here. I asked to get some corner cases tested with the following code in matlab


function test_min_only (varargin)
  narginchk (3)
  disp ('only minargs is ok')
end

function test_same (varargin)
  narginchk (3, 3)
  disp ('min and max can be equal')
end

function test_inf (varargin)
  narginchk (3, inf)
  disp ('can use inf as max')
end

function test_zero (varargin)
  narginchk (0, 3)
  disp ('can use zero as min')
end

function test_zero_both (varargin)
  narginchk (0, 0)
  disp ('can use zero as both min and max')
end

function test_negative (varargin)
  narginchk (-1, 3)
  disp ('min can be negative')
end

test_min_only (1, 2, 3)   # fails
test_same (1, 2, 3)       # works
test_inf (1, 2, 3)        # works
test_zero (1, 2, 3)       # works
test_zero_both ()         # works
test_negative (1, 2, 3)   # works


Carnë Draug <carandraug>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #24234:  narginchk.diff added by carandraug (5KiB - text/x-patch)
file #24232:  narginchk.diff added by carandraug (3KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by carandraug (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-11-10 jordigh StatusNone Done
        Assigned toNone jordigh
        Open/ClosedOpen Closed
    2011-10-28 carandraug Attached File- Added narginchk.diff, #24234
    2011-10-28 carandraug Attached File- Added narginchk.diff, #24232

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code