From: Alan G I. <ai...@am...> - 2006-08-21 15:22:36
|
The definition of linspace is: def linspace(start, stop, num=3D50, endpoint=3DTrue, retstep=3DFalse): """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 the step value used. """ num =3D int(num) if num <=3D 0: return array([], float) if endpoint: if num =3D=3D 1: return array([float(start)]) step =3D (stop-start)/float((num-1)) else: step =3D (stop-start)/float(num) y =3D _nx.arange(0, num) * step + start if retstep: return y, step else: return y The simplest way to achieve this goal is to add right after=20 the assignment to y two new lines: if endpoint: y[-1] =3D float(stop) Cheers, Alan Isaac PS I'll take this opportunity to state again my opinion that in the denerate case num=3D1 that if endpoint=3DTrue then=20 linspace should return stop rather than start. (Otherwise=20 endpoint is ignored. But I do not expect anyone to agree.) |