[Numpy-discussion] numarray bug: dot product between 2x2 and 3x2x3 on Mac different from PC
Sebastian Haase
haase at msg.ucsf.edu
Mon Jul 17 14:40:43 EDT 2006
Thanks Chris,
If this got fixed towards numarray version 1.5.1 it looks like
it is now on both Linux and Mac
different(!) from the numpy result I got on Window !!
On Linux I get:
>>> import numpy as N
>>> N.__version__
'0.9.9.2823'
>>> bbb=N.zeros((2,3,3), N.float32)
>>> bbb[0,:,:]=1
>>> bbb[1,:,:]=2
>>> bbb
[[[ 1. 1. 1.]
[ 1. 1. 1.]
[ 1. 1. 1.]]
[[ 2. 2. 2.]
[ 2. 2. 2.]
[ 2. 2. 2.]]]
>>> ccc=N.transpose(bbb,(1,0,2))
>>> d=N.array([[1,0],[0,1]])
>>> d
[[1 0]
[0 1]]
>>> N.dot(d,ccc)
Traceback (most recent call last):
File "<input>", line 1, in ?
TypeError: array cannot be safely cast to required type
>>> dd=d.astype(N.float32)
>>> N.dot(dd,ccc)
[[[ 1. 1. 1.]
[ 1. 1. 1.]
[ 1. 1. 1.]]
[[ 2. 2. 2.]
[ 2. 2. 2.]
[ 2. 2. 2.]]]
>>>
The TypeError looks like a numpy bug !
Thanks,
Sebastian Haase
On Monday 17 July 2006 11:29, Christopher Barker wrote:
> And on my Mac:
>
> OS-X 10.4.*, PPC, universal python 2.4.3:
> >>> import numarray as na
> >>> na.__version__
>
> '1.5.1'
>
> >>> bbb=na.zeros((2,3,3), na.Float32)
> >>> bbb[0,:,:]=1
> >>> bbb[1,:,:]=2
> >>> ccc=na.transpose(bbb,(1,0,2))
> >>> d=na.array([[1,0],[0,1]])
> >>> na.dot(d,ccc)
>
> array([[[ 1., 1., 1.],
> [ 2., 2., 2.],
> [ 1., 1., 1.]],
>
> [[ 2., 2., 2.],
> [ 1., 1., 1.],
> [ 2., 2., 2.]]], type=Float32)
More information about the NumPy-Discussion
mailing list