[Numpy-discussion] generating float sequences

Alan G Isaac aisaac@american....
Fri Aug 22 21:09:26 CDT 2008

Chris Fonnesbeck wrote:
> Is there any prospect for easily getting ranges of floats 
> in numpy, rather than just integers?

     >>> help(np.linspace)
     Help on function linspace in module numpy.lib.function_base:

     linspace(start, stop, num=50, endpoint=True, retstep=False)
         Return evenly spaced numbers.

         Return num evenly spaced samples from start to stop.  If
         endpoint is True, the last sample is stop. If retstep is
         True then return (seq, step_value), where step_value used.

> for a sequence from 0 to 100 in steps of 0.1. It seems rather unpythonic to 
> have to do this:
> arange(0, 1000)/10. 

I find it plenty Pythonic,
although it is not the answer to your question.  ;-)

Alan Isaac

More information about the Numpy-discussion mailing list