[Numpy-discussion] range/arange

Travis Oliphant oliphant at ee.byu.edu
Thu Apr 13 10:49:06 CDT 2006


Arnd Baecker wrote:

>On Thu, 13 Apr 2006, Lars Bittrich wrote:
>
>  
>
>>Hi,
>>
>>On Thursday 13 April 2006 11:07, Pierre GM wrote:
>>    
>>
>>>Could any of you explain me why the two following commands give different
>>>results ? It's mere curiosity, for my personal edification.
>>>
>>>[(m-5)/10 for m in arange(1,10)]
>>>[0, 0, 0, 0, 0, 0, 0, 0, 0]
>>>
>>>[(m-5)/10 for m in range(1,10)]
>>>[-1, -1, -1, -1, 0, 0, 0, 0, 0]
>>>      
>>>
>>I have no idea where the reason is located exactly, but it seems to be caused
>>by different types of range and arange.
>>    
>>
>
>
>Interestingly with Numeric you get the following:
>
>In [1]: from Numeric import *
>In [2]: [(m-5)/10 for m in arange(1,10)]
>Out[2]: [-1, -1, -1, -1, 0, 0, 0, 0, 0]
>In [3]: type(arange(1,10)[0])
>Out[3]: <type 'int'>
>
>Will this cause any trouble for projects
>transitioning from Numeric to numpy?
>Presumably a proper explanation (which?)
>should go into the scipy wiki ("Converting from Numeric").
>
>  
>
Yes, some discussion will be needed about the fact that NumPy now has 
its own scalars.    This will give us quite a bit more flexibility 
moving forward and should be seamless for the most part.

-Travis





More information about the Numpy-discussion mailing list