[Numpy-discussion] alternative mechanism for initializing an array
Thu Jul 16 22:22:33 CDT 2009
On 16-Jul-09, at 9:34 PM, Phillip M. Feldman wrote:
> This does the right thing sometimes, but not always. Out and
> are fine, but Out is not (note the extra set of braces). Probably
> the only right way to fix this is to modify numpy itself.
yes, to achieve out you'd need myarray(1,2,3).
A .squeeze() after it would fix that, but it would also make it
impossible to create the array [[]] if you really wanted it for
Basically the current syntax is the only ambiguity-free way I can
think of that makes any sense. And NumPy was designed by some very
smart people so I doubt I'll be able to top their best idea. :P
One idea would be an object like mgrid that creates arrays via
__getitem__ so that you could do foo[[1,2,3]] to get [[1,2,3]],
foo[1,2,3] to get [1,2,3]... That'd get rid of a set of parens but
it'd also be mighty confusing.
More information about the NumPy-Discussion