[Insight-users] Python wrapping broken?

Charl P. Botha c.p.botha at ewi.tudelft.nl
Tue, 02 Mar 2004 22:42:40 +0100


This is a multi-part message in MIME format.
--------------050807030206040802030103
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Charl P. Botha wrote:
> If you have a build of ITK CVS of today, could you try running:
> 
> python GeodesicActiveContourImageFilter.py \
> ../Data/BrainProtonDensitySlice.png lventricle.png \
> 81 114 5 1 -0.5 3 2
> 
> in Insight/Examples/Segmentation?  I'm getting the following traceback:
> 
> Traceback (most recent call last):
>   File "GeodesicActiveContourImageFilter.py", line 185, in ?
>     main()
>   File "GeodesicActiveContourImageFilter.py", line 56, in main
>     sigmoid.SetOutputMinimum(  0.0  )
>   File "/home/cpbotha/build/Insight-gcc/bin/itkSigmoidImageFilter.py",
> line 803, in SetOutputMinimum
>     def SetOutputMinimum(*args): return
> _itkSigmoidImageFilter.itkSigmoidImageFilterF2F2_Pointer_SetOutputMinimum(*args)
> OverflowError: value %g is less than float minimum %g
> 
> This worked just a few days ago.

It seems the new SWIG is the problem: the SWIG developers misunderstood
the meaning of FLT_MIN.  I've fixed this and I would like to apply the
attached patch (in Insight/Utilities/CableSwig/SWIG/Lib/python/).  Brad,
could you take a look at this and if you agree please notify the SWIG
developers?

FLT_MIN is not what one expects.  See:
http://mail.gnome.org/archives/gtk-devel-list/2001-June/msg00309.html
http://mail.gnome.org/archives/gtk-devel-list/2001-June/msg00308.html

I'm now chasing the next Python wrapping problem.  After having applied
above patch,  GeodesicActiveContourImageFilter.py now breaks with this:

Traceback (most recent call last):
    File "GeodesicActiveContourImageFilter.py", line 185, in ?
      main()
    File "GeodesicActiveContourImageFilter.py", line 103, in main
      seedPosition.SetElement(0, float(sys.argv[3]))
    File "/home/cpbotha/build/Insight-gcc/bin/itkIndex.py", line 87, in
SetElement
      def SetElement(*args): return _itkIndex.itkIndex2_SetElement(*args)
SystemError: ../Objects/longobject.c:188: bad argument to internal function

Thanks,
Charl

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/



--------------050807030206040802030103
Content-Type: text/plain;
 name="pyprimtypes.flt_min_fix.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="pyprimtypes.flt_min_fix.diff"

Index: pyprimtypes.swg
===================================================================
RCS file: /cvsroot/CableSwig/CableSwig/SWIG/Lib/python/pyprimtypes.swg,v
retrieving revision 1.2
diff -u -r1.2 pyprimtypes.swg
--- pyprimtypes.swg	18 Feb 2004 14:45:29 -0000	1.2
+++ pyprimtypes.swg	2 Mar 2004 21:26:24 -0000
 at  at  -269,10 +269,10  at  at 
 {
   float f = 0;
   if (!PyErr_Occurred()) {
-    if (value < FLT_MIN) {
+    if (value < -FLT_MAX) {
       PyObject *err = 
-        PyString_FromFormat("value %g is less than float minimum %g", 
-			    value, FLT_MIN);
+        PyString_FromFormat("value %g is less than most negative float %g",
+			    value, -FLT_MAX);
       PyErr_SetObject(PyExc_OverflowError, err);
       Py_DECREF(err);
     } else if (value > FLT_MAX) {


--------------050807030206040802030103--