[SciPy-dev] cephes.tandg test

Arnd Baecker arnd.baecker at web.de
Wed Jan 11 06:46:12 CST 2006


Hi,

On Wed, 11 Jan 2006, David M. Cooke wrote:

> On Jan 10, 2006, at 09:35 , Arnd Baecker wrote:
[...]
> > DESIRED: 1.0
> > ACTUAL: 1.0000000000000002
> > ----------------------------------------------------------------------
> >
> > The is caused by the strict equality test:
> >
> >     def check_tandg(self):
> >         assert_equal(cephes.tandg(45),1.0)
> >
> > Is there a reason, why one should get 1.0 up to the last bit?
> > If not an `assert_almost_equal` might be more appropriate?
>
> Well, I'd argue that if you've gone to the trouble of making a
> version of tan that takes degrees, it *should* return exact values
> for those that it can (tan(0) = 0, tan(+-45) = +-1).
>
> The cephes code was weird enough that it could miss that, so I added
> a special case test
> http://projects.scipy.org/scipy/scipy/changeset/1545
>
> See if it works now.

Well:

======================================================================
FAIL: check_cotdg (scipy.special.basic.test_basic.test_cotdg)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/home/baecker/python2/scipy_lintst_n_nothing/lib/python2.4/site-packages/scipy/special/tests/test_basic.py",
line 771, in check_cotdg
    assert_almost_equal(ct,ctrl,8)
  File
"/home/baecker/python2//scipy_lintst_n_nothing/lib/python2.4/site-packages/numpy/testing/utils.py",
line 101, in assert_almost_equal
    assert round(abs(desired - actual),decimal) == 0, msg
AssertionError:
Items are not equal:
DESIRED: 1.7320508075688774
ACTUAL: nan

======================================================================
FAIL: check_specialpoints (scipy.special.basic.test_basic.test_tandg)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/home/baecker/python2/scipy_lintst_n_nothing/lib/python2.4/site-packages/scipy/special/tests/test_basic.py",
line 2016, in check_specialpoints
    assert_equal(tandg(-45), -1.0)
  File
"/home/baecker/python2//scipy_lintst_n_nothing/lib/python2.4/site-packages/numpy/testing/utils.py",
line 81, in assert_equal
    assert desired == actual, msg
AssertionError:
Items are not equal:
DESIRED: -1.0
ACTUAL: 1.0

======================================================================
FAIL: check_tandg (scipy.special.basic.test_basic.test_tandg)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/home/baecker/python2/scipy_lintst_n_nothing/lib/python2.4/site-packages/scipy/special/tests/test_basic.py",
line 2003, in check_tandg
    assert_almost_equal(tn,tnrl,8)
  File
"/home/baecker/python2//scipy_lintst_n_nothing/lib/python2.4/site-packages/numpy/testing/utils.py",
line 101, in assert_almost_equal
    assert round(abs(desired - actual),decimal) == 0, msg
AssertionError:
Items are not equal:
DESIRED: 0.57735026918962573
ACTUAL: 0.0

======================================================================
FAIL: check_tandgmore (scipy.special.basic.test_basic.test_tandg)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/home/baecker/python2/scipy_lintst_n_nothing/lib/python2.4/site-packages/scipy/special/tests/test_basic.py",
line 2011, in check_tandgmore
    assert_almost_equal(tnm1,tnmrl1,8)
  File
"/home/baecker/python2//scipy_lintst_n_nothing/lib/python2.4/site-packages/numpy/testing/utils.py",
line 101, in assert_almost_equal
    assert round(abs(desired - actual),decimal) == 0, msg
AssertionError:
Items are not equal:
DESIRED: 1.7320508075688767
ACTUAL: 1.0

Clearly, something weird is going on ...

In [1]: import numpy
In [2]: numpy.__version__
Out[2]: '0.9.3.1863'
In [3]: import scipy
Overwriting fft=<function fft at 0x2000000001474668> from
scipy.fftpack.basic (was <function fft at 0x2000000001394a28> from
numpy.dft.fftpack)
Overwriting ifft=<function ifft at 0x20000000014746e0> from
scipy.fftpack.basic (was <function inverse_fft at 0x2000000001394aa0> from
numpy.dft.fftpack)
._
In [4]: scipy.__version__
Out[4]: '0.4.4.1545'

(BTW: I really don't like those "Overwriting" messages,
and I also have reservations about steering that with an environment
variable - but that's a different subject).

What can I do to find out what is going wrong with tandg
(not that I need that function at all, but a failing unit
test could point to something deeper ...)

Best, Arnd




More information about the Scipy-dev mailing list