2 May
2007
2 May
'07
6:45 p.m.
Pierre GM wrote:
If you need your inputs to be array or scalar and stay that way
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: import numpy as N
def test(a): ... b = N.asarray(a, dtype=N.float).reshape((-1,)) ... print b.shape ...
test(5) (1,) test((5,)) (1,) test((5,6,7,8)) (4,)
-- 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