[SciPy-user] is there a difference between numpy and scipy array ?
Robert Kern
robert.kern at gmail.com
Sun Jan 14 16:18:36 CST 2007
Stef Mientki wrote:
>
>
> 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 ;-)
No, that example doesn't even run. If there ever were a difference, it's long
gone (although for the life of me I cannot remember a time when there was a
numpy package and a scipy package each with their own ndarray).
In [1]: import numpy
In [2]: import scipy
In [3]: a1 = numpy.zeros((3,3))
In [4]: type(a1)
Out[4]: <type 'numpy.ndarray'>
In [5]: a2 = scipy.zeros((3,3))
In [6]: type(a2)
Out[6]: <type 'numpy.ndarray'>
In [7]: print numpy.__version__
1.0.2.dev3507
In [8]: print scipy.__version__
0.5.3.dev2500
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-user
mailing list