[Numpy-discussion] For-less code
Wed Feb 24 23:52:54 CST 2010
I am working on a code shown at
I use the code to analyse a couple dataset also placed in the same
directory. In the first part I use for-loops all over, but later decided to
write them without using for loops. The script runs correctly for the two
section, however I have a few question regarding to the for-less structures:
This part is taken after line 371:
gm10 = np.exp((1/Nt10)*(h10*np.log(Dp)).sum(axis=1))
a10 = (dN_dDp10[0:300,d >= dc10u]*0.001).sum(axis=1)
Shape informations for the arrays as follow:
I: gm10.shape; gsd10.shape, Dp.shape, d.shape, dN_dDp10.shape,
O: (300,), (300,), (11,), (991,), (300, 991), (300,)
1-) In gsd10 line what does axis=-1 really means, and why negative axis
value is allowed?
2-) [:,np.newaxis] decreases the readability of the code. Is there any
alternative for it?
3-) In the last line (dN_dDp10[0:300,d >= dc10u]) could I achieve the same
result with different syntax? I have found it somewhat not in accordance
with the previous lines.
Thanks for your time and comments.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion