assignment to matrix slice in Numeric bug/feature?
hello, I've found that the following fragment of code gives an error while with other shapes of b there is no problem: ---------------------------- #!/usr/bin/python2 from Numeric import * from Matrix import * a = Matrix(zeros([4,4])) b = Matrix(ones([2,1])) print a, a.shape print b, b.shape q = a[1:3,1:2] print q, q.shape a[1:3,1:2] = b ----------------------------- resulting in: ------------------------------------- Matrix([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) (4, 4) Matrix([[1], [1]]) (2, 1) Matrix([[0], [0]]) (2, 1) Traceback (most recent call last): File "./numpybug.py", line 11, in ? a[1:3,1:2] = b File "/usr/lib/python2.1/site-packages/Numeric/Matrix.py", line 180, in __setitem__ def __setitem__(self, index, value): self.array[index] = asarray(squeeze(value),self._typecode) ValueError: matrices are not aligned for copy ----------------------------------------------- The mentioned behaviour looks like a bug, because a[1:3,1:2] and b have the same shape and according to docs b must be copied to a-slice 1:1... Numeric is version 21.0, Python 2.1 under Linux RedHat 7.2. Thank you in advance! Sincerely yours, Roman Suzi -- \_ Russia \_ Karelia \_ Petrozavodsk \_ rnd@onego.ru \_ \_ Saturday, May 18, 2002 \_ Powered by Linux RedHat 7.2 \_
On Tue, 21 May 2002, Roman Suzi wrote:
hello,
I've found that the following fragment of code gives an error while with other shapes of b there is no problem:
...
The mentioned behaviour looks like a bug, because a[1:3,1:2] and b have the same shape and according to docs b must be copied to a-slice 1:1...
Numeric is version 21.0, Python 2.1 under Linux RedHat 7.2.
Thank you in advance!
For the record: - the bug is fixed in CVS. Thank you, guys! Sincerely yours, Roman Suzi -- \_ Russia \_ Karelia \_ Petrozavodsk \_ rnd@onego.ru \_ \_ Saturday, May 25, 2002 \_ Powered by Linux RedHat 7.2 \_ \_ "... All the world's a stage, and I missed rehearsal." \_
participants (1)
-
Roman Suzi