help-octave
[Top][All Lists]
Advanced

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

Re: firls.m, part 2


From: Nicholas Jankowski
Subject: Re: firls.m, part 2
Date: Tue, 20 Jun 2017 14:06:52 -0400

On Tue, Jun 20, 2017 at 1:52 PM, je suis <address@hidden> wrote:
>Should I delete those and replace
> them with the %! tyoe checks you gave as example?
>
> Vlad

no, you need both as they serve different purposes. The ones at the
end are just built-in self-tests that are only checked when running
"test firls" as a way of making sure you didn't break anything when
changing some code. Especially important when someone else has to
later make changes to code they didn't write.

For example, there has been a good deal of discussion about focusing
on code optimization. This will likely require people to dive into
code they didn't write and look for ways to improve efficiency/speed.
It is paramount that the function outputs still meet all requirements
for form, and numerical accuracy. The self-tests retain that
information. They can also capture nuances about Matlab compatibility,
etc, that might not obviously be necessary for the primary numerical
operation.

In short: The checks in your function are part of the code executed
when you call the function.  The tests at the end just verify that
those work.

Looking at the last few tests in the newer expint:

## Test input validation
%!error expint ()
%!error expint (1,2)
%!error <X must be numeric> expint ("1")

just verify that the function's input checks are working, and that it
throws an error if you don't give the correct arguments to expint.
Those three tests are passed if an error is produced. The third one is
only passed if that correct message is produced. (you can verify that
if fails 'correctly'.)

The earlier tests verify numeric output, and you can specify the
degree of desired precision (1e-12 for most)

Nick J.



reply via email to

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