Numarray append

Alex Martelli aleax at aleax.it
Sat Nov 9 18:06:32 EST 2002


Fabrizio wrote:

> Is there a quick way to append elements to a Numarray array ?
> 
> I could not find any.

Numeric arrays aren't quite as flexible as Python lists, but some
ways can be found, e.g.:

>>> x = Numeric.arrayrange(7)
>>> def numarext(aray, oth):
...     L = len(aray)
...     aray = Numeric.resize(aray, (L+len(oth),) )
...     aray[L:] = oth
...     return aray
...
>>> x = numarext(x, range(3))
>>> x
array([0, 1, 2, 3, 4, 5, 6, 0, 1, 2])
>>>


Alex




More information about the Python-list mailing list