Pierre GM wrote:
It didn't sound like the OP wanted that. I suspect that what is wanted if for to always be a 1-d array (i.e. vector). To do that, I'd do:
I beg to differ: your option is equivalent to (and I suspect a bit slower than) atleast_1d, which is what the OP complained about...
There is a difference, but I don't know what the OP wanted. my method (N.asarray(a, dtype-N.float).reshape((-1,)) will ALWAYS create a 1-d array, even if the original is greater than 1-d atleast_1d will let an n-d array pass through. It also doesn't look like you can specify a data type with atleast_1d. I don't think my approach is slower, as it handles the conversion to float, and reshape doesn't copy the data if it doesn't need to. But I doubt speed makes any difference here anyway. -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov