[Numpy-discussion] Strange behaviour of numpy.asarray() in corner case
Friedrich Romstedt
friedrichromstedt at gmail.com
Fri Jan 28 13:23:15 EST 2011
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.5.1'
>>> class X:
... pass
...
>>> numpy.asarray([X(), numpy.asarray([1, 1])]).shape
(2,)
>>> numpy.asarray([numpy.asarray([1, 1]), X()]).shape
()
>>>
I would expect (2,) in the second case too. The following works ok:
>>> numpy.asarray([1, X()]).shape
(2,)
>>> numpy.asarray([X(), 1]).shape
(2,)
Friedrich
More information about the NumPy-Discussion
mailing list