Skip to content

test_distance.test_Xdist_deprecated_args test error in 0.19.0rc2 #7100

@matthew-brett

Description

@matthew-brett

Testing the 0.19.0rc2 wheel gives a new test error, only seen for Python 3.6, 64-bit and numpy 1.11.3:

======================================================================
ERROR: test_distance.test_Xdist_deprecated_args
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/venv/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/venv/lib/python3.6/site-packages/scipy/spatial/tests/test_distance.py", line 1549, in test_Xdist_deprecated_args
    cdist(X1, X1, metric, **kwargs)
  File "/venv/lib/python3.6/site-packages/scipy/spatial/distance.py", line 2156, in cdist
    VI = _validate_mahalanobis_args(np.vstack([XA, XB]), mA + mB, n, VI)
  File "/venv/lib/python3.6/site-packages/scipy/spatial/distance.py", line 199, in _validate_mahalanobis_args
    VI = np.linalg.inv(CV).T.copy()
  File "/venv/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 526, in inv
    ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
  File "/venv/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 90, in _raise_linalgerror_singular
    raise LinAlgError("Singular matrix")
numpy.linalg.linalg.LinAlgError: Singular matrix

See: https://travis-ci.org/MacPython/scipy-wheels/jobs/205362487

I can replicate this on OpenBLAS-linked scipy, Python 3.6. To my surprise, the X1 matrix in the traceback above changes over the course of the loop. At the time of error X1 is:

array([[ -1.00000000e+00,   0.00000000e+00,   1.00000000e+00],
       [ -1.10000000e+00,  -1.48029737e-16,   1.10000000e+00],
       [ -7.66666667e-01,  -6.66666667e-01,   1.43333333e+00],
       [ -7.76666667e+00,  -6.66666667e+00,   1.44333333e+01]])

The covariance CV above is:

array([[  9.95769841,   9.36984127, -19.32753968],
       [  9.36984127,   8.98412698, -18.35396825],
       [-19.32753968, -18.35396825,  37.68150794]])

and this is rank deficient:

(pdb) np.linalg.svd(CV, compute_uv=False)
array([  5.65348586e+01,   8.84747019e-02,   4.28472602e-16])

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectA clear bug or issue that prevents SciPy from being installed or used as expectedscipy.spatial

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions