|
From: Stefan v. d. W. <st...@su...> - 2006-02-19 21:36:10
|
On Sat, Feb 18, 2006 at 06:20:50PM -0700, Travis Oliphant wrote:
> Stefan van der Walt wrote:
>=20
> >I am probably trying to do something silly, but still:
> >
> >In [1]: import numpy as N
> >
> >In [2]: N.__version__
> >Out[2]: '0.9.6.2127'
> >
> >In [3]: P =3D N.array(N.zeros((2,2)), N.dtype((('f4',3), {'names':=20
> >['x','y','z'], 'formats': ['f4','f4','f4']})))
> >*** glibc detected *** malloc(): memory corruption: 0x0830bb48 ***
> >Aborted
> >
> >Regards
> >St=E9fan
> >=20
> >
> This code found a bug that's been there for a while in the=20
> PyArray_CastTo code (only seen on multiple copies) which is being done=20
> here as the 2x2 array of zeros is being cast to a 2x2x3 array of=20
> floating-point zeros.
>=20
> The bug should be fixed in SVN, now.
Thank you very much for fixing this! (It works now).
> Despite the use of fields, the base-type is ('f4',3) which is equivalen=
t=20
> to (tack on a 3 to the shape of the array of 'f4'). So, on array=20
> creation the fields will be lost and you will get a 2x2x3 array of=20
> float32. Types like ('f4', 3) are really only meant to be used in=20
> records. If they are used "by themselves" they simply create an array=20
> of larger dimension. =20
<snip insightful explanation>
Exactly what I needed for my application! I'll write this up and put
it on the wiki.
Cheers
St=E9fan
|