[Numpy-discussion] converting scalar to array with dimension 1

Bill Baxter wbaxter@gmail....
Fri Mar 30 15:04:04 CDT 2007

On 3/31/07, P GM <pgmdevlist@gmail.com> wrote:
> Actually, there's even faster than that:
> a = 3
> a = array(a, ndmin=1)
> atleast_1d is nothing but a wrapper function, that works best when used with
> several inputs. When using only one array as inputs, the trick above should
> be more appropriate.

I think you'll want to add the copy=False arg if you go that route, or
else you'll end up with something that's much slower than atleast_1d
for any array that gets passed in.  :-)

  a = array(a, copy=0,ndmin=1)

Anyway, sounds like premature optimization to me.


More information about the Numpy-discussion mailing list