#11334: Update numpy to 1.7.0
--------------------------------------------------------------+-------------
       Reporter:  jason                                       |         Owner:  
tbd     
           Type:  task                                        |        Status:  
new     
       Priority:  major                                       |     Milestone:  
sage-5.7
      Component:  packages                                    |    Resolution:  
        
       Keywords:  sd40.5                                      |   Work issues:  
        
Report Upstream:  Fixed upstream, in a later stable release.  |     Reviewers:  
        
        Authors:                                              |     Merged in:  
        
   Dependencies:  #12415, #13992                              |      Stopgaps:  
        
--------------------------------------------------------------+-------------

Comment (by strogdon):

 This references the failure in the test
 {{{
 sage -t -long -force_lib "devel/sage-main/sage/plot/matrix_plot.py"
 }}}
 I have some concerns with the following block of code in matrix_plot.py
 {{{
     try:
         if sparse:
             xy_data_array = mat
         else:
             xy_data_array = np.asarray(mat, dtype = float)
     except TypeError:
         raise TypeError, "mat must be a Matrix or a two dimensional array"
     except ValueError:
         raise ValueError, "can not convert entries to floating point
 numbers"

     if len(xy_data_array.shape) < 2:
         raise TypeError, "mat must be a Matrix or a two dimensional array"
 }}}
 The subject failure occurs when the object "mat" is not sparse. In which
 case, the errors are thrown by
 {{{
 np.asarray(mat, dtype = float)
 }}}
 I have not been able to pass any object "mat" to np.asarray() that returns
 a {{{TypeError}}} or {{{ValueError}}}
 that remotely hints of the cause as being due to
 {{{
 "mat must be a Matrix or a two dimensional array"
 }}}
 I question whether this information can be returned by np.asarray() when
 used from Sage. I could be wrong though. The referenced failure does
 return a {{{TypeError}}}
 [http://trac.sagemath.org/sage_trac/ticket/11334#comment:68 See above].
 But this error reflects the inability to coerce the symbolic [sin(x),
 cos(x)] expressions to floats. It is possible to generate a
 {{{ValueError}}} when the object "mat" contains complex entries:
 {{{
 sage: import numpy
 sage: numpy.asarray([[1+1j,2+3j],[1,1]], dtype=float)
 ---------------------------------------------------------------------------
 ValueError                                Traceback (most recent call
 last)
 <ipython-input-5-2bd7229efabd> in <module>()
 ----> 1 numpy.asarray([[Integer(1)+ComplexNumber(0,
 '1'),Integer(2)+ComplexNumber(0, '3')],[Integer(1),Integer(1)]],
 dtype=float)

 /storage/sage/sage-5.7.beta3/local/lib/python2.7/site-
 packages/numpy/core/numeric.pyc in asarray(a, dtype, order)
     318
     319     """
 --> 320     return array(a, dtype, copy=False, order=order)
     321
     322 def asanyarray(a, dtype=None, order=None):

 ValueError: setting an array element with a sequence.
 }}}
 This is they type of error that's returned for the referenced test when
 using numpy-1.5.1. Sage interprets this error as
 {{{
 "can not convert entries to floating point numbers"
 }}}
 This seems to be a correct interpretation, at least from the python side
 with the numpy of this ticket:
 {{{
 >>> import numpy
 >>> numpy.asarray([[1+1j,2+3j],[1,1]], dtype=float)
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/storage/sage/sage-5.7.beta3/local/lib/python2.7/site-
 packages/numpy/core/numeric.py", line 320, in asarray
     return array(a, dtype, copy=False, order=order)
 TypeError: can't convert complex to float
 }}}
 although here there is a {{{TypeError}}}?

 So it seems to me that regardless of whether there is a {{{TypeError}}} or
 {{{ValueError}}} the root cause is inability to coerce to a float. The
 question of whether "mat" is a Matrix or appropriate array is determined
 by the lines in the code that parse the shape attribute of an object that
 has been successfully converted to a ndarray. But this is probably minor
 compared to #12415. Perhaps Mike (mhansen) has some input?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11334#comment:86>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to