mark wrote:
> OK, so in my example, I get a zero dimension array. Apparently a
> feature, not a bug.
> What I don't understand is why it isn't an array of lenght one? (or:
> why it isn't a bug?)

Because we need a way to get rank-0 arrays.

> Is there any use for a zero dimension array?

http://projects.scipy.org/scipy/numpy/wiki/ZeroRankArray

> I would very much like it to be a one dimension array.
> In my application I don' t know whether an integer, float, or array
> gets passed to the function.
> This is my syntax:
> def test(a):
>    b = asarray(a,'d')
>    do something to b....
> I thought this makes b an array AND a float. The atleast_1d only makes
> it an array, not necessarily a float.
> Any more thoughts on how to do this cleanly?

atleast_1d(a).astype(float)

Put it into a function if you want that to be more concise.

> Any reason NOT to have asarray(3,'d') return an array of length 1?

Because we need a way to get a rank-0 array.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to