2011/2/9 Mark Bakker <[email protected]>: > a = array([1,2,3]) > > I want to take the last two terms and make it a column vector: > > a[[1,2],newaxis] > a[[1,2]][:,newaxis]
The former is advanced indexing, while the latter is basic slicing (after advanced indexing). See http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html. There, in the advanced indexing case, "All sequences and scalars in the selection tuple are converted to intp indexing arrays", and: >>> numpy.intp <type 'numpy.int32'> . Thus it tries to interpret the None: >>> numpy.newaxis >>> print repr(numpy.newaxis) None as an ``numpy.intp``, hence the error. Since advanced indexing deletes axes of an ndarray and inserts new ones (see http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#integer, last point), a ``numpy.newaxis`` might be ambiguous. In your case, it would be not, though. Friedrich _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
