[SciPy-user] is there a difference between numpy and scipy array ?
Stef Mientki
s.mientki at ru.nl
Sun Jan 14 16:10:21 EST 2007
Robert Kern wrote:
> Stef Mientki wrote:
>
>> Forgive my ignorance, but reading more and more docs,
>> I now get he feeling there's a difference between Numpy en Scipy arrays,
>> is that so ?
>>
>
> No. scipy is a package that *uses* numpy. That's all.
>
>
I found it again:
from: SciPy Course Outline, by
Author: Dave Kuhlman
At times you may need to convert an array from one type to another, for
example from a numpy array to a scipy array or the reverse. The array
protocol will help. In particular, the asarray() function can convert an
array without copying. Examples:
In [8]: import numpy
In [9]: import scipy
In [10]: a1 = zeros((4,6))
In [11]: type(a1)
Out[11]: <type 'scipy.ndarray'>
In [12]: a2 = numpy.asarray(a1)
In [13]: type(a2)
Out[13]: <type 'numpy.ndarray'>
In [14]: a3 = numpy.zeros((3,5))
In [15]: type(a3)
Out[15]: <type 'numpy.ndarray'>
In [16]: a4 = scipy.asarray(a3)
In [17]: type(a4)
Out[17]: <type 'scipy.ndarray'>
So after all there is a difference,
but I still don't know what exactly the difference is ;-)
== now something weird happens here:
[Dbg]>>> aap=(11,12,11,23)
[Dbg]>>> type(aap)
<type 'tuple'>
[Dbg]>>> IOI=scipy.asarray(aap) <== make it a scipy array
[Dbg]>>> print IOI
[11 12 11 23]
[Dbg]>>> type(IOI)
<type 'numpy.ndarray'> <== it has NOT become a scipy array ??
Maybe in general this (small ?) difference might not make a big deal,
but as I want to do real calculations, with mainly scipy functions,
I want to optimize the array type
(probably i4, but maybe f8 is even faster depending on the kind of calculations)
cheers,
Stef Mientki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20070114/d6c20afa/attachment.html>
More information about the SciPy-User
mailing list