[Numpy-discussion] Dimension checking on assignment

Berthold Höllmann hoel at gl-group.com
Wed Dec 10 06:27:01 CST 2003


For some time now I waws searching for the cause of a segmentation
fault in a quite complex piece of software of ours which occured only
under Windows and not under Linux nor under Solaris. Finally it seems
that the case were some lines that did the following:

from Numeric import *
import numeric_version
print numeric_version.version
from numfort import arrayInfo
import sys
print sys.version
m = ones((48,6,8), Complex)
m = transpose(m,[2,0,1])
a =swapaxes(innerproduct(transpose([[1,0,0],[0,1,0],[0,0,1]]),m[:,:,:3]),0,-1)
print a.typecode()
print "arrayInfo(m):"
print "arrayInfo(a):"
print m[:,:,:3].shape
print a.shape
print m[1,1,1]
print m[1,1,1]
print m[1,1,1]

the nuarray.arrayInfo just prints the dimensions and strides of a
Numeric array. With this script I get

>python ~/xx.py
2.2.1 (#1, Dec 13 2002, 10:37:32) 
[GCC 3.2]
3 dimensions, dimensions : 8 48 6, strides : 1 48 8
3 dimensions, dimensions : 48 8 3, strides : 1 48 384
(8, 48, 3)
(48, 8, 3)
Segmentation fault

under Linux. The code does not segfault when I print m in whole
("print m" instead of "print m[1,1,1]") and it does not segfault in my
compelex program. It does segfault in my complex program under
Windows.  Versions are 2.3.2 for python and 23.1 for Numeric under
Windows. The main question is, why is no exception raised on the
incompatible dimensions in this example?

Kind regards

Berthold Höllmann
Germanischer Lloyd AG
CAE Development
Vorsetzen 35
20459 Hamburg
Phone: +49(0)40 36149-7374
Fax: +49(0)40 36149-7320
e-mail: hoel at gl-group.com
Internet: http://www.gl-group.com 
Please notice: We would like to inform you that the e-mail address of Germanischer Lloyd as well as our internet address had been changed to  gl-group.com with effect from 1st March 2003. 
This means that the previous address shortmark at germanlloyd.org will be replaced by shortmark at gl-group.com. From now on the GL homepage can be accessed at the address 'http://www.gl-group.com'. The old addresses remain valid for a transitional period. 
This e-mail contains confidential information for the exclusive attention of the intended addressee. Any access of third parties to this e-mail is unauthorised. Any use of this e-mail by unintended recipients such as copying, distribution, disclosure etc. is prohibited and may be unlawful. When addressed to our clients the content of this e-mail is subject to the General Terms and Conditions of GL's Group of Companies applicable at the date of this e-mail.  
GL's Group of Companies does not warrant and/or guarantee that this message at the moment of receipt is authentic, correct and its communication free of errors, interruption etc.  

More information about the Numpy-discussion mailing list