[Numpy-discussion] immediate fill after empty gives None.

Johannes Loehnert a.u.r.e.l.i.a.n at gmx.net
Fri Jun 30 05:13:22 EDT 2006


Hi,

> Opteron 64-bit, r2631 SVN.
>
> In [4]: depths_s2 = empty(shape=(5,),dtype=float)
> In [5]: depths_s2.fill(2.e5)
> In [6]: depths_s2
> Out[6]: array([ 200000.,  200000.,  200000.,  200000.,  200000.])
>
> In [11]: depths_s2 = (empty(shape=(5,),dtype=float)).fill(2.e5)
> In [12]: print depths_s2
> None

everything is fine. x.fill() fills x in-place and returns nothing. So in line 
11, you created an array, filled it with 2.e5, assigned the return value of 
fill() (=None) to depths_s2 and threw the array away.

HTH, Johannes




More information about the NumPy-Discussion mailing list