[SciPy-User] [SciPy-user] Avoiding inner for loops??

mdekauwe mdekauwe at gmail.com
Tue Aug 21 20:14:59 EDT 2012


Hi, 

> You may like to utilize functionality of ix_ and newaxis, like:
In []: p1, p2, p3= ix_(param1, param2, param3)
In []: n_= newaxis
In []: ans= fake_model(data1[:, n_, n_, n_], data2[:, n_, n_, n_], p1, p2,
p3)
In []: ss2= ((obs[:, n_, n_, n_]- ans).sum(0)** 2).reshape(grid_size** 3)
In []: allclose(ss, ss2)
Out[]: True


My 2 cents,
-eat

This solution is exactly what I was looking for thank you. I hadn't come
across np.ix_ before.

-- 
View this message in context: http://old.nabble.com/Avoiding-inner-for-loops---tp34319763p34332203.html
Sent from the Scipy-User mailing list archive at Nabble.com.




More information about the SciPy-User mailing list