[Numpy-discussion] high dimensional array -> python scalar/index
Sebastian Berg
sebastian at sipsolutions.net
Sun Jan 6 12:57:21 EST 2013
Question for everyone, is this really reasonable:
>>> import numpy as np
>>> from operator import index
>>> index(np.array([[5]]))
5
>>> int(np.array([[5]]))
5
>>> [0,1,2,3][np.array([[2]])]
2
To me, this does not make sense, why should we allow to use a high
dimensional object like a normal scalar (its ok for 0-d arrays I guess)?
Personally I would be for deprecating these usages, even if that
(probably) means you cannot reshape your array with a matrix (as it is
2D) ;-):
>>> np.arange(10).reshape(np.matrix([5,-1]).T)
array([[0, 1],
[2, 3],
[4, 5],
[6, 7],
[8, 9]])
More information about the NumPy-Discussion
mailing list