#4491: finance.TimeSeries from numpy array doesn't work correctly
---------------------+------------------------------------------------------
 Reporter:  ghtdak   |        Owner:  jason     
     Type:  defect   |       Status:  assigned  
 Priority:  minor    |    Milestone:  sage-3.2.1
Component:  finance  |   Resolution:            
 Keywords:           |  
---------------------+------------------------------------------------------
Comment (by jason):

 Okay, this will taken care of as part of the vector RDF/CDF rewrite (since
 that already touched the relevant parts of the timeseries code).  Timing
 results for the case that worked before (simple double numpy arrays)
 indicate a 3x slowdown.  The new code should work for any numpy datatype
 (the current code does not) and any sort of numpy array.

 before patch:
 {{{
 sage: import numpy as np
 sage: a=np.array(range(1e2), dtype='double')
 sage: %timeit b=finance.TimeSeries(a)
 100000 loops, best of 3: 2.13 µs per loop
 sage: a=np.array(range(1e3), dtype='double')
 sage: %timeit b=finance.TimeSeries(a)
 100000 loops, best of 3: 3.51 µs per loop
 sage: a=np.array(range(1e4), dtype='double')
 sage: %timeit b=finance.TimeSeries(a)
 10000 loops, best of 3: 21.6 µs per loop
 sage: a=np.array(range(1e5), dtype='double')
 sage: %timeit b=finance.TimeSeries(a)
 100 loops, best of 3: 1.85 ms per loop
 sage: a=np.array(range(1e6), dtype='double')
 sage: %timeit b=finance.TimeSeries(a)
 10 loops, best of 3: 18.5 ms per loop
 sage: a=np.array(range(1e7), dtype='double')
 sage: %timeit b=finance.TimeSeries(a)double')
 10 loops, best of 3: 189 ms per loop
 }}}

 after patch:

 {{{
 sage: sage: import numpy as np
 sage: sage: a=np.array(range(1e2), dtype='double')
 sage: sage: %timeit b=finance.TimeSeries(a)
 100000 loops, best of 3: 5.77 µs per loop
 sage: sage: a=np.array(range(1e3), dtype='double')
 sage: sage: %timeit b=finance.TimeSeries(a)
 100000 loops, best of 3: 8.74 µs per loop
 sage: sage: a=np.array(range(1e4), dtype='double')
 sage: sage: %timeit b=finance.TimeSeries(a)
 10000 loops, best of 3: 52.3 µs per loop
 sage: sage: a=np.array(range(1e5), dtype='double')
 sage: sage: %timeit b=finance.TimeSeries(a)
 100 loops, best of 3: 3.83 ms per loop
 sage: sage: a=np.array(range(1e6), dtype='double')
 sage: sage: %timeit b=finance.TimeSeries(a)
 10 loops, best of 3: 36.3 ms per loop
 sage: sage: a=np.array(range(1e7), dtype='double')
 sage: sage: %timeit b=finance.TimeSeries(a)
 10 loops, best of 3: 365 ms per loop
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/4491#comment:5>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
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