[SciPy-User] Does SciPy already supersed NumPy?

Thøger Emil Rivera-Thorsen trive at astro.su.se
Tue Sep 30 11:24:24 EDT 2014


Oh wow - I have always imported everything Numpy through simply doing
|import scipy as sp| because that was one less import statement and gave
everything I needed from Numpy. What is worse, I have been teaching my
students that this is more convenient.

What are the reasons this is not recommended?


On 09/30/2014 05:18 PM, Robert Kern wrote:

> On Mon, Sep 29, 2014 at 5:49 PM, Sergio Rojas <sergio_r at mail.com> wrote:
>> In the not so long past we were suppose to do:
>>
>>>>> import numpy as np
>>>>> anumpy = np.arange(15).reshape(3, 5)
>>>>> anumpy
>> array([[ 0,  1,  2,  3,  4],
>>        [ 5,  6,  7,  8,  9],
>>        [10, 11, 12, 13, 14]])
>>>>> anumpy.shape
>> (3, 5)
>>>>> anumpy.ndim
>> 2
>>>>> np.array([6, 7, 8])
>> array([6, 7, 8])
>>
>> Now, one can also do:
>>
>>>>> import scipy as sp
>>>>> sp.__version__
>> '0.13.3'
>>>>> ascipy = sp.arange(15).reshape(3, 5)
>>>>> ascipy
>> array([[ 0,  1,  2,  3,  4],
>>        [ 5,  6,  7,  8,  9],
>>        [10, 11, 12, 13, 14]])
>>>>> ascipy.shape
>> (3, 5)
>>>>> ascipy.ndim
>> 2
>>>>> sp.array([6, 7, 8])
>> array([6, 7, 8])
>>
>> Is it recomended to do so?
>>
>>  Does this means that SciPy has overloaded NumPy functions or that SciPy
>> superseding NumPy?
> No. See this section of the documentation:
>
> http://docs.scipy.org/doc/scipy/reference/api.html#guidelines-for-importing-functions-from-scipy
>
>
>
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140930/78116ef9/attachment.html>


More information about the SciPy-User mailing list