[SciPy-dev] Using doctest

Travis Oliphant oliphant at ee.byu.edu
Sun Oct 30 10:14:00 CST 2005

>Another point:
>Running the tests of newcore from "normal" python gives:
>ERROR: doctest of scipy.base.polynomial.test_polynomial
>Traceback (most recent call last):
>  File "/usr/lib/python2.3/unittest.py", line 423, in runTest
>    self.__testFunc()
>  File "/usr/lib/python2.3/doctest.py", line 1359, in runit
>    _utest(tester, name, doc, filename, lineno)
>  File "/usr/lib/python2.3/doctest.py", line 1309, in _utest
>    raise DocTestTestFailure('Failed doctest test for %s\n'
>DocTestTestFailure: Failed doctest test for
>  File
>line 1 (or above), in test_polynomial
>Failure in example: p / q
>from line #28 of scipy.base.polynomial.test_polynomial
>Exception raised:
>Traceback (most recent call last):
>  File "/usr/lib/python2.3/doctest.py", line 442, in _run_examples_inner
>    compileflags, 1) in globs
>  File "<string>", line 1, in ?
>  File
>line 489, in __div__
>    return map(poly1d, polydiv(self.coeffs, other.coeffs))
>  File
>line 313, in polydiv
>    q, r = deconvolve(a1, a2)
>  File
>line 305, in deconvolve
>    quot = scipy.signal.lfilter(num, den, input)
>UnboundLocalError: local variable 'scipy' referenced before assignment
>The reason is the use of scipy.signal in polynomial.py,
>def deconvolve(signal, divisor):
>    """Deconvolves divisor out of signal.  Requires scipy.signal library
>    """
>    try:
>        import scipy.signal
>    except ImportError:
>        print "You need scipy.signal to use this function."
>    [...]
>This routine does not work if only newcore is installed.
>If I understood things correctly, newcore should
>be independent from newscipy, or?

newcore should be installable, but there can be a few functions that 
require other scipy packages.  This is the appropriate way to handle it, 
I think.

The test for deconvolve should be moved over to scipy.signal or else an 
appropriate try block used.


More information about the Scipy-dev mailing list