[Numpy-discussion] Simplifying array()
Colin J. Williams
cjw at sympatico.ca
Thu Jan 13 15:09:13 CST 2005
Ralf Juengling wrote:
>On Thu, 2005-01-13 at 09:00, Tim Hochberg wrote:
>>>It would be good to clarify the acceptable content of a sequence.
>>>A list, perhaps with sublists, of numbers is clear enough but what
>>>about a sequence of NumArray instances or even a sequence of
>>>numbers, mixed with NumArray instances?
>>Isn't any sequence that is composed of numbers or subsequences
>>acceptable, as long as it has a consistent shape (no ragged edges)?
>Why not make it a little more general and accept iterable objects?
>>From http://docs.python.org/lib/module-array.html :
> Return a new array whose items are restricted by typecode, and
> initialized from the optional initializer value, which must be a
> list, string, or iterable over elements of the appropriate type.
> Changed in version 2.4: Formerly, only lists or strings were
> accepted. If given a list or string, the initializer is passed
> to the new array's fromlist(), fromstring(), or fromunicode()
> method (see below) to add initial items to the array. Otherwise,
> the iterable initializer is passed to the extend() method.
Yes, I'm not sure whether list comprehension produces an iter object but
this should also be included.
Similarly instances of subclasses of NumArray should be explicitly included.
I like the term no "ragged edges".
More information about the Numpy-discussion