On Fri, Jun 5, 2009 at 1:33 PM, Geoffrey Ely <g...@usc.edu> wrote: > On Jun 5, 2009, at 10:18 AM, josef.p...@gmail.com wrote: >> I'm only using arrays for consistency, but my econometrics code is >> filled with arr[np.newaxis,:] . > > > arr[None,:] is a lot cleaner in my opinion, especially when using > "numpy" as the namespace.
It took me a long time to figure out that None and np.newaxis do the same thing. I find newaxis more descriptive and mostly stick to it. When I started looking at numpy, I was always wondering what these "None"s were doing in the code. just one more useful trick to preserve dimension, using slices instead of index avoids arr[None,:], but requires more thinking. Josef >>> X matrix([[1, 0], [1, 1]]) >>> Y array([[1, 0], [1, 1]]) >>> X[0,:].shape == Y[0:1,:].shape True >>> X[0,:] == Y[0:1,:] matrix([[ True, True]], dtype=bool) > -Geoff _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion