dkazanc / TomoPhantom

Software to generate 2D/3D/4D analytical phantoms and their Radon transforms (parallel beam) for image processing
https://dkazanc.github.io/TomoPhantom/
Apache License 2.0
116 stars 53 forks source link

DemoObject3D.py crashes for Python 2.7 #39

Closed dkazanc closed 5 years ago

dkazanc commented 5 years ago

DemoObject3D.py runs from Python 3.5 but crashes with "kernel died" from 2.7. It seems

    if type(objlist) is dict:
        objlist = [objlist]

    for obj in objlist:
        if testParamsPY(obj):
            if sys.version_info.major == 3:
                objectName = bytes(obj['Obj'].value, 'ascii')
            elif sys.version_info.major == 2:
                objectName = bytes(obj['Obj'].value)

somewhat responsible in TomoP3D.pyx?

paskino commented 5 years ago

My guess is that the cast to float isn't right for Python 2.7. We should do that with proper ctypes.

Try casting with ctypes.c_float(obj['C0']) instead float(obj['C0']), etc.

dkazanc commented 5 years ago

by cast to float you mean the function call, where:

                                        float(obj['C0']),
                                        float(obj['x0']),
                                        float(obj['y0']),
                                        float(obj['z0']),
                                        float(obj['a']),
                                        float(obj['b']),
                                        float(obj['c']), 
                                        float(obj['phi1']),
                                        float(obj['phi2']), 
                                        float(obj['phi3']), 0)
paskino commented 5 years ago

yes

paskino commented 5 years ago

I believe that in the short term I will create 2 different pyx files for Python 3 and 2. In the long term we shall use ctypes.

dkazanc commented 5 years ago

Fine by me, it's a bit of a hassle really.

paskino commented 5 years ago

Is this still relevant?

dkazanc commented 5 years ago

the issue persists for Python 2.7

dkazanc commented 5 years ago

fails also with 3.5...

dkazanc commented 5 years ago

73 fixes the problem