[Scipy-svn] r3498 - trunk/scipy/odr

scipy-svn at scipy.org scipy-svn at scipy.org
Mon Nov 5 18:13:19 EST 2007


Author: rkern
Date: 2007-11-05 17:13:01 -0600 (Mon, 05 Nov 2007)
New Revision: 3498

Modified:
   trunk/scipy/odr/__odrpack.c
   trunk/scipy/odr/odrpack.py
Log:
Use C-int arrays instead of C-long arrays. Fix #357.

Modified: trunk/scipy/odr/__odrpack.c
===================================================================
--- trunk/scipy/odr/__odrpack.c	2007-11-04 04:35:10 UTC (rev 3497)
+++ trunk/scipy/odr/__odrpack.c	2007-11-05 23:13:01 UTC (rev 3498)
@@ -920,7 +920,7 @@
   if (pifixb == NULL)
     {
       dim1[0] = np;
-      ifixb = (PyArrayObject *) PyArray_FromDims(1, dim1, PyArray_LONG);
+      ifixb = (PyArrayObject *) PyArray_FromDims(1, dim1, PyArray_INT);
       *(int *)(ifixb->data) = -1;      /* set first element negative */
     }
   else
@@ -928,7 +928,7 @@
       /* pifixb is a sequence as checked before */
 
       if ((ifixb =
-           (PyArrayObject *) PyArray_CopyFromObject(pifixb, PyArray_LONG, 1,
+           (PyArrayObject *) PyArray_CopyFromObject(pifixb, PyArray_INT, 1,
                                                     1)) == NULL)
         {
           PYERR(PyExc_ValueError,
@@ -946,7 +946,7 @@
     {
       dim2[0] = m;
       dim2[1] = 1;
-      ifixx = (PyArrayObject *) PyArray_FromDims(2, dim2, PyArray_LONG);
+      ifixx = (PyArrayObject *) PyArray_FromDims(2, dim2, PyArray_INT);
       *(int *)(ifixx->data) = -1;      /* set first element negative */
       ldifx = 1;
     }
@@ -955,7 +955,7 @@
       /* pifixx is a sequence as checked before */
 
       if ((ifixx =
-           (PyArrayObject *) PyArray_CopyFromObject(pifixx, PyArray_LONG, 1,
+           (PyArrayObject *) PyArray_CopyFromObject(pifixx, PyArray_INT, 1,
                                                     2)) == NULL)
         {
           PYERR(PyExc_ValueError,
@@ -1169,7 +1169,7 @@
   if (piwork != NULL)
     {
       if ((iwork =
-           (PyArrayObject *) PyArray_CopyFromObject(piwork, PyArray_LONG, 1,
+           (PyArrayObject *) PyArray_CopyFromObject(piwork, PyArray_INT, 1,
                                                     1)) == NULL)
         {
           PYERR(PyExc_ValueError,
@@ -1185,7 +1185,7 @@
     {
       /* initialize our own iwork array */
       dim1[0] = liwork;
-      iwork = (PyArrayObject *) PyArray_FromDims(1, dim1, PyArray_LONG);
+      iwork = (PyArrayObject *) PyArray_FromDims(1, dim1, PyArray_INT);
     }                           /* iwork */
 
   /* check if what JOB requests can be done with what the user has 

Modified: trunk/scipy/odr/odrpack.py
===================================================================
--- trunk/scipy/odr/odrpack.py	2007-11-04 04:35:10 UTC (rev 3497)
+++ trunk/scipy/odr/odrpack.py	2007-11-05 23:13:01 UTC (rev 3498)
@@ -107,14 +107,17 @@
 odr_stop = __odrpack.odr_stop
 
 
-def _conv(obj):
+def _conv(obj, dtype=None):
     """ Convert an object to the preferred form for input to the odr routine.
     """
 
     if obj is None:
         return obj
     else:
-        obj = numpy.asarray(obj)
+        if dtype is None:
+            obj = numpy.asarray(obj)
+        else:
+            obj = numpy.asarray(obj, dtype)
         if obj.shape == ():
             # Scalar.
             return obj.dtype.type(obj)
@@ -708,8 +711,11 @@
             self.beta0 = _conv(beta0)
 
         self.delta0 = _conv(delta0)
-        self.ifixx = _conv(ifixx)
-        self.ifixb = _conv(ifixb)
+        # These really are 32-bit integers in FORTRAN (gfortran), even on 64-bit
+        # platforms.
+        # XXX: some other FORTRAN compilers may not agree.
+        self.ifixx = _conv(ifixx, dtype=numpy.int32)
+        self.ifixb = _conv(ifixb, dtype=numpy.int32)
         self.job = job
         self.iprint = iprint
         self.errfile = errfile




More information about the Scipy-svn mailing list