#13081: Add a numpy() method to all vectors.
-----------------------------------+----------------------------------------
       Reporter:  robertwb         |         Owner:  jason, was                 
           Type:  defect           |        Status:  needs_work                 
       Priority:  major            |     Milestone:  sage-5.1                   
      Component:  linear algebra   |    Resolution:                             
       Keywords:                   |   Work issues:  better error with bad dtype
Report Upstream:  N/A              |     Reviewers:  Karl-Dieter Crisman        
        Authors:  Robert Bradshaw  |     Merged in:                             
   Dependencies:                   |      Stopgaps:                             
-----------------------------------+----------------------------------------
Changes (by {'newvalue': u'Robert Bradshaw', 'oldvalue': ''}):

  * status:  needs_review => needs_work
  * reviewer:  => Karl-Dieter Crisman
  * work_issues:  => better error with bad dtype
  * author:  => Robert Bradshaw


Comment:

 This looks pretty good overall.  It would be nice for the newbie to have a
 little more documentation, maybe, of other `dype`s built in to Sage,
 especially since not all the ones listed
 [http://docs.scipy.org/doc/numpy/user/basics.types.html here] are
 available.  Which ones are?  I found `int`, `bool`, `complex`, `float`,
 but not all of the specific bit or `uint` ones.  Also, where the heck does
 `object` get predefined?  In `stdsage.something`?

 {{{
 sage: v = vector([i,3/4,55.6])
 sage: v.numpy(dtype=complex)
 array([  0.00+1.j,   0.75+0.j,  55.60+0.j])
 sage: w = vector([-2,3, 4.0])
 sage: w.numpy(dtype=bool)
 array([ True,  True,  True], dtype=bool)
 }}}

 I do think we need a better error message in the case that Sage has the
 dtype, but it's not valid.

 {{{
 sage: v = vector([i,3/4,55.6])
 sage: v.numpy(dtype=int)
 ---------------------------------------------------------------------------
 <snip>
 ValueError: setting an array element with a sequence.
 }}}

 Finally, though it's not directly relevant to this ticket, why can't I
 bring a numpy thing directly back to Sage?  I can do `vector(v.numpy())`
 but apparently not just `v.nump()._sage_()`.  Strange.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13081#comment:3>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to