[Scipy-tickets] [SciPy] #1701: csgraph.shortest_path failures

SciPy Trac scipy-tickets@scipy....
Sat Jul 14 10:18:26 CDT 2012


#1701: csgraph.shortest_path failures
----------------------------------+-----------------------------------------
 Reporter:  rgommers              |       Owner:  jakevdp
     Type:  defect                |      Status:  new    
 Priority:  normal                |   Milestone:  0.11.0 
Component:  scipy.sparse.csgraph  |     Version:  0.10.0 
 Keywords:  shortest_path         |  
----------------------------------+-----------------------------------------

Comment(by rgommers):

 So the failures only seem to occur due to something in johnson().

 When I use {{{return_predecessors=True}}}, the
 {{{test_shortest_path_indices}}} seem to go away.
 {{{
 diff --git a/scipy/sparse/csgraph/tests/test_shortest_path.py
 b/scipy/sparse/csgraph/tests/test_shortest_path.py
 index 5f54fbf..5a948d1 100644
 --- a/scipy/sparse/csgraph/tests/test_shortest_path.py
 +++ b/scipy/sparse/csgraph/tests/test_shortest_path.py
 @@ -79,8 +79,8 @@ def test_shortest_path_indices():

      def check(func, indshape):
          outshape = indshape + (5,)
 -        SP = func(directed_G, directed=False,
 -                  indices=indices.reshape(indshape))
 +        SP, _ = func(directed_G, directed=False,
 +                  indices=indices.reshape(indshape),
 return_predecessors=True)
          assert_array_almost_equal(SP,
 undirected_SP[indices].reshape(outshape))
 }}}

 Although then sometimes an invalid value (nan, inf) seems to come by:
 {{{
 ======================================================================
 ERROR: test_shortest_path.test_undirected('J', False)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6
 /site-packages/nose-1.1.2-py2.6.egg/nose/case.py", line 197, in runTest
     self.test(*self.arg)
   File
 "/Users/rgommers/Code/scipy/scipy/sparse/csgraph/tests/test_shortest_path.py",
 line 69, in check
     overwrite=False)
   File "_shortest_path.pyx", line 151, in
 scipy.sparse.csgraph._shortest_path.shortest_path
 (build/scons/scipy/sparse/csgraph/_shortest_path.c:2244)
   File "_shortest_path.pyx", line 921, in
 scipy.sparse.csgraph._shortest_path.johnson
 (build/scons/scipy/sparse/csgraph/_shortest_path.c:9099)
 RuntimeWarning: invalid value encountered in add

 ======================================================================
 ERROR: test_shortest_path.test_shortest_path_indices(<built-in function
 johnson>, (4,))
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6
 /site-packages/nose-1.1.2-py2.6.egg/nose/case.py", line 197, in runTest
     self.test(*self.arg)
   File
 "/Users/rgommers/Code/scipy/scipy/sparse/csgraph/tests/test_shortest_path.py",
 line 83, in check
     indices=indices.reshape(indshape), return_predecessors=True)
   File "_shortest_path.pyx", line 921, in
 scipy.sparse.csgraph._shortest_path.johnson
 (build/scons/scipy/sparse/csgraph/_shortest_path.c:9099)
 RuntimeWarning: invalid value encountered in add

 ----------------------------------------------------------------------
 }}}

 I looked at the way {predecessor_matrix}}} is initialized and used, but
 don't see something obviously wrong.  Although making it a size 0 2-D
 array is a bit odd.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1701#comment:3>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list