Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-18 Thread Terry Reedy
On 11/17/2015 3:51 PM, fl wrote: n_iter = 50 sz = (n_iter,) # size of array x = -0.37727 z = np.random.normal(x,0.1,size=sz) Q = 1e-5 # process variance # allocate space for arrays xhat=np.zeros(sz) P=np.zeros(sz) I learn Python now and the above code seems from an experienced author. The

Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-18 Thread Dave Farrance
fl wrote: >Hi, >I find the following code snippet, which is useful in my project: > ... >correctly. Could you see something useful with variable 'sz'? So that's example code in "An Introduction to the Kalman Filter" by Greg Welch and Gary Bishop, and no, that construct was

Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-17 Thread John Gordon
In fl writes: > correctly. Could you see something useful with variable 'sz'? 'sz' is fewer characters than '(n_iter,)', which may make your code easier to read. The np.zeros() function explicitly accepts an 'int or

Is there any reason to introduce this intermediate variable (sz)?

2015-11-17 Thread fl
Hi, I find the following code snippet, which is useful in my project: n_iter = 50 sz = (n_iter,) # size of array x = -0.37727 z = np.random.normal(x,0.1,size=sz) Q = 1e-5 # process variance # allocate space for arrays xhat=np.zeros(sz) P=np.zeros(sz) I learn Python now and

Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-17 Thread fl
On Tuesday, November 17, 2015 at 4:03:05 PM UTC-5, John Gordon wrote: > In fl <@gmail.com> > writes: > > > correctly. Could you see something useful with variable 'sz'? > > 'sz' is fewer characters than '(n_iter,)', which may make your

Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-17 Thread John Gordon
In fl writes: > I still don't see the necessity of 'sz'. Thanks, sz isn't required. You can use (n_iter,) in place of sz. However, as I posted earlier, sz is shorter so it might make your code easier to read. Using

Re: Is there any reason to introduce this intermediate variable (sz)?

2015-11-17 Thread Mark Lawrence
On 17/11/2015 21:27, fl wrote: On Tuesday, November 17, 2015 at 4:03:05 PM UTC-5, John Gordon wrote: In fl <@gmail.com> writes: correctly. Could you see something useful with variable 'sz'? 'sz' is fewer characters than '(n_iter,)',