[Numpy-discussion] numpy.ndarray constructor from python list: bug?

Emanuele Olivetti emanuele@relativita....
Thu Mar 6 03:53:36 CST 2008


Dear all,

Look at this little example:
----
import numpy
a = numpy.array([1])
b = numpy.array([1,2,a])
c = numpy.array([a,1,2])
----
Which has the following output:
----
Traceback (most recent call last):
  File "b.py", line 4, in <module>
    c = numpy.array([a,1,2])
ValueError: setting an array element with a sequence.
----

It seems that a list starting with an ndarray ('a', of
a single number) is not a legal input to build an ndarray.
Instead if 'a' is in other places of the list the ndarray
builds up flawlessly.

Is there a meaning for this behavior or is it a bug?

Details: numpy 1.04 on ubuntu linux x86_64


Emanuele



More information about the Numpy-discussion mailing list