[Numpy-discussion] Numeric/numpy difference
Travis Oliphant
oliphant.travis at ieee.org
Tue Jan 24 08:01:08 CST 2006
Jens Jorgen Mortensen wrote:
> I just discovered (the hard way) that:
>
> >>> import numpy
> >>> a = numpy.empty((2, 3))
> >>> a[:] = [1, 2]
> >>> a
> array([[1, 2, 1],
> [2, 1, 2]])
>
> This is with revision 1984. With Numeric I get "ValueError: matrices
> are not aligned for copy", which I think is the correct answer.
Well, not necessarily. This is consistent behavior with a[:] = 3 which
fills the array with 3's. What's happening is that the array is being
filled with [1,2] repeatedly (in C-contiguous order).
-Travis
More information about the Numpy-discussion
mailing list