violación de segmento en pyrex

Daniel danielj en iai.csic.es
Mar Ene 25 16:41:58 CET 2005


Hola,
me ocurre una cosa muy rara y muy "incómoda".
estoy haciendo una aplicación muy sencillita que invoca funciones
definidas en pyrex.
Ya tengo algunas que fucionaban bien, pero haciendo pruebas me está
dando problemas y no puedo volver a la situación anterior.
El caso es que ahora, cuando llamo a alguna funcion del módulo generado
con pyrex el python "casca" con el mensaje violación de segmento.

He probado con código antiguo, que si funcionaba y obtengo el mismo
error.
He probado reiniciar la máquina (como no), y nada.
He probado a recompilar el codigo en pyrex (.pyx) y nada
He probado, también, borrarlo todo (carpeta build incluida), a cambiarle
el nombre, nada...

si llamo a una función pyrex (ejecutamdo s.py) me produce violación de
segmento.

Si alguien puede arrojar algo de luz sobre este misterio tan misterioso
le estaría muy agradecido.

Dani.

El código es:

pyx_hist.pyx   _____________________________________________________
#
#Inspirado en un codigo de Prabhu Ramachandran 
# compilar con  "python setup.py build_ext --inplace"

    ctypedef class Numeric.ArrayType [object PyArrayObject]:
          cdef char *data
          cdef int nd
          cdef int *dimensions, *strides
          cdef object base
          cdef PyArray_Descr *descr
          cdef int flags
def pyrexHistograma(ArrayType h, ArrayType tiempo, ArrayType aj):
    cdef int cnt,longitud
    cdef double *h_d, *tiempo_d, *aj_d
    cdef int tiempo_int

    h_d = <double *>h.data
    tiempo_d = <double *>tiempo.data
    aj_d = <double *>aj.data

    longuitud = tiempo.dimensions[0]
    for cnt from 0 <= cnt < longitud:
        tiempo_int = tiempo_d[cnt]
        h_d[tiempo_int]=h_d[tiempo_int]+aj_d[cnt]
    return h

setup.py ___________________________________________________________
from distutils.core import setup, Extension
from Pyrex.Distutils import build_ext

setup(
    name = 'Histograma',
    ext_modules=[ Extension("pyx_hist", ["pyx_hist.pyx"]) ],
    cmdclass = {'build_ext': build_ext}
    )

s.py _______________________________________________________________
from Numeric import *
from pyx_hist import *

h = array([0,0,0,0,0])
tiempo = array([0,1,1,2,2,2])
aj = array([1,1,1,1,1,1])
print pyrexHistograma(h,tiempo,aj)




Más información sobre la lista de distribución Python-es