[Numpy-discussion] asarray() behaviour.

Tim Leslie tim.leslie at gmail.com
Mon Jan 8 21:55:06 EST 2007

I get different behaviour from asarray depending on whether I pass in
a list or an array, Additionally, neither of them give me the expected
results, which is a TypeError complaining about being unable to use
complex values as floats. Can someone shed some light on this.



In [27]: N.asarray([1j,2,3], dtype=N.float64)
exceptions.ValueError                                Traceback (most
recent call last)

/home/timl/src/scipy/Lib/linsolve/<ipython console>

/usr/lib/python2.4/site-packages/numpy/core/numeric.py in asarray(a,
dtype, order)
    130     are converted to base class ndarray.
    131     """
--> 132     return array(a, dtype, copy=False, order=order)
    134 def asanyarray(a, dtype=None, order=None):

ValueError: setting an array element with a sequence.

In [28]: N.asarray(N.array([1j,2,3]), dtype=N.float64)
Out[28]: array([ 0.,  2.,  3.])

More information about the NumPy-Discussion mailing list