[SciPy-dev] scipy.interpolate missing functions

Anne Archibald peridot.faceted at gmail.com
Mon Apr 21 22:59:19 EDT 2008


On 21/04/2008, Stéfan van der Walt <stefan at sun.ac.za> wrote:
> On 21/04/2008, Anne Archibald <peridot.faceted at gmail.com> wrote:
>  >  a missing import. Not surprisingly, it wasn't tested either. Attached
>  >  is a patch to fix all three issues (though I haven't tested it because
>  >  I have not yet figured out how to compile a local version of scipy
>  >  that (a) doesn't clobber my real installation and (b) actually works).
>
> I install SciPy to my home directory:
>
>  python setup.py install --prefix=${HOME}
>
>  and then make sure that
>
>  ${HOME}/lib/python2.5/site-packages
>
>  is in the PYTHONPATH.

Ah, got it working, nose, cython, eggs, and all.

>  As for (b), what specifically goes wrong?

Well, the problem I had when I sent the email was version skew between
numpy and scipy. I've cured that; now I have a fistful of test
failures:

======================================================================
ERROR: Tests pdist(X, 'cosine') on the Iris data set.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/cluster/tests/test_hierarchy.py",
line 263, in test_pdist_cosine_iris
    Y_test1 = pdist(X, 'cosine')
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/cluster/hierarchy.py",
line 1410, in pdist
    dm = squareform(dm)
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/cluster/hierarchy.py",
line 766, in squareform
    raise ValueError('The distance matrix must be symmetrical.')
ValueError: The distance matrix must be symmetrical.

======================================================================
ERROR: Tests pdist(X, 'cosine') on random data.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/cluster/tests/test_hierarchy.py",
line 244, in test_pdist_cosine_random
    Y_test1 = pdist(X, 'cosine')
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/cluster/hierarchy.py",
line 1410, in pdist
    dm = squareform(dm)
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/cluster/hierarchy.py",
line 766, in squareform
    raise ValueError('The distance matrix must be symmetrical.')
ValueError: The distance matrix must be symmetrical.

======================================================================
ERROR: Failure: ImportError (cannot import name _bspline)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peridot/devlib/lib/python2.5/site-packages/nose-0.10.1-py2.5.egg/nose/loader.py",
line 364, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/peridot/devlib/lib/python2.5/site-packages/nose-0.10.1-py2.5.egg/nose/importer.py",
line 39, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/peridot/devlib/lib/python2.5/site-packages/nose-0.10.1-py2.5.egg/nose/importer.py",
line 84, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/tests/test_bspline.py",
line 9, in <module>
    import scipy.stats.models.bspline as B
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/bspline.py",
line 23, in <module>
    from scipy.stats.models import _bspline
ImportError: cannot import name _bspline

======================================================================
ERROR: test_factor3 (test_formula.TestFormula)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/tests/test_formula.py",
line 231, in test_factor3
    m = fac.main_effect(reference=1)
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/formula.py",
line 273, in main_effect
    reference = names.index(reference)
ValueError: list.index(x): x not in list

======================================================================
ERROR: test_factor4 (test_formula.TestFormula)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/tests/test_formula.py",
line 239, in test_factor4
    m = fac.main_effect(reference=2)
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/formula.py",
line 273, in main_effect
    reference = names.index(reference)
ValueError: list.index(x): x not in list

======================================================================
ERROR: test_huber (test_scale.TestScale)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/tests/test_scale.py",
line 35, in test_huber
    m = scale.huber(X)
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/robust/scale.py",
line 82, in __call__
    for donothing in self:
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/robust/scale.py",
line 102, in next
    scale = N.sum(subset * (a - mu)**2, axis=self.axis) / (self.n *
Huber.gamma - N.sum(1. - subset, axis=self.axis) * Huber.c**2)
  File "/home/peridot/devlib/lib/python2.5/site-packages/numpy/core/fromnumeric.py",
line 930, in sum
    return sum(axis, dtype, out)
TypeError: only length-1 arrays can be converted to Python scalars

======================================================================
ERROR: test_huberaxes (test_scale.TestScale)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/tests/test_scale.py",
line 40, in test_huberaxes
    m = scale.huber(X, axis=0)
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/robust/scale.py",
line 82, in __call__
    for donothing in self:
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/robust/scale.py",
line 102, in next
    scale = N.sum(subset * (a - mu)**2, axis=self.axis) / (self.n *
Huber.gamma - N.sum(1. - subset, axis=self.axis) * Huber.c**2)
  File "/home/peridot/devlib/lib/python2.5/site-packages/numpy/core/fromnumeric.py",
line 930, in sum
    return sum(axis, dtype, out)
TypeError: only length-1 arrays can be converted to Python scalars

======================================================================
FAIL: test_gammaincinv (test_basic.TestGamma)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/special/tests/test_basic.py",
line 1056, in test_gammaincinv
    assert_almost_equal(0.05, x, decimal=10)
  File "/home/peridot/devlib/lib/python2.5/site-packages/numpy/testing/utils.py",
line 158, in assert_almost_equal
    assert round(abs(desired - actual),decimal) == 0, msg
AssertionError:
Items are not equal:
 ACTUAL: 0.050000000000000003
 DESIRED: 0.0

======================================================================
FAIL: test_namespace (test_formula.TestFormula)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/peridot/devlib/lib/python2.5/site-packages/scipy/stats/models/tests/test_formula.py",
line 119, in test_namespace
    self.assertEqual(xx.namespace, Y.namespace)
AssertionError: {} != {'Y': array([ 0,  2,  4,  6,  8, 10, 12, 14, 16,
18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40,
       42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72,
74, 76, 78, 80, 82,
       84, 86, 88, 90, 92, 94, 96, 98]), 'X': array([ 0,  1,  2,  3,
4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
       21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41,
       42, 43, 44, 45, 46, 47, 48, 49])}

I probably don't have development versions of ATLAS and whatnot
installed, but scipy purports to have installed correctly. (Well,
there is the usual monstrous stream of messages, but none of them
appear to indicate that I should expect a broken installation.)

I am able to test scipy.interpolate, and with a minor fix, lagrange()
now passes its test. I have write access to numpy SVN, which
apparently gives me write access to scipy SVN too (though I haven't
tried committing anything). Should I just check in the fix, or file a
bug and attach a patch?

Anne


More information about the SciPy-Dev mailing list