[Numpy-discussion] Generating a series of integers

Francesc Altet faltet at carabos.com
Tue Feb 5 05:33:39 EST 2008


Hi,

I need to generate a series of uint8 integers similar to:

In [37]: numpy.linspace(10, 20, num=25).astype('uint8')
Out[37]:
array([10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 15, 15, 15, 16,
       16, 17, 17, 17, 18, 18, 19, 19, 20], dtype=uint8)

i.e. create evenly spaced samples in a range, but without using an 
intermediate array to create it (memory footprint is important).

I know that I can create this with a loop, but I'm curious if that can 
be done more compactly in one single sentence.

Thanks,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"



More information about the NumPy-Discussion mailing list