[SciPy-dev] Numeric CVS __array_struct__ interface is broken on 64 bit platforms

Andrew Straw strawman at astraw.com
Wed Nov 9 16:17:03 EST 2005


Thanks, Travis.  That works and now scipy.test(10,10) passes with 2 
failures in check_l_bfgs_b.

Thanks again, I'm very excited about the new scipy!

======================================================================
FAIL: limited-memory bound-constrained BFGS algorithm
----------------------------------------------------------------------
Traceback (most recent call last):
   File 
"/home/astraw/py24-amd64-dbg/lib/python2.4/site-packages/scipy/optimize/tests/test_optimize.py", 
line 120, in check_l_bfgs_b
     assert err < 1e-6
AssertionError

======================================================================
FAIL: limited-memory bound-constrained BFGS algorithm
----------------------------------------------------------------------
Traceback (most recent call last):
   File 
"/home/astraw/py24-amd64-dbg/lib/python2.4/site-packages/scipy/optimize/tests/test_optimize.py", 
line 120, in check_l_bfgs_b
     assert err < 1e-6
AssertionError

----------------------------------------------------------------------
Ran 1346 tests in 127.339s

FAILED (failures=2)
<unittest.TextTestRunner object at 0x2aaab28c4a78>
[2132778 refs]




Travis Oliphant wrote:
> Nils Wagner wrote:
> 
>> On Wed, 09 Nov 2005 12:35:34 -0700
>>  Travis Oliphant <oliphant at ee.byu.edu> wrote:
>>  
>>
>>> Andrew Straw wrote:
>>>
>>>   
>>>
>>>> Hi,
>>>>
>>>> A couple bugs have been reported (including mine last night) which
>>>> indicate a problem with the following bit of code in
>>>> Numerical/Src/arrayobject.c (near line 2200) on 64 bit platforms.  I
>>>> think it'll be a lot faster for someone else to fix it, so I'll 
>>>> leave it
>>>> at this for now.
>>>>
>>>>
>>>>     
>>>
>>> Try it out of CVS now.  I think I've fixed it.
>>>
>>>   
>>
>> cvs -d:pserver:anonymous at cvs.sourceforge.net:/cvsroot/numpy co -P 
>> Numerical
>> cvs [checkout aborted]: connect to 
>> cvs.sourceforge.net(66.35.250.207):2401 failed: Connection refused
>>  
>>
> I don't know, must be a sourceforge issue.  Note, however, that 
> anonymous check-out from source forge usually lags.  I'm attaching a 
> patch against Numeric 24.1 that fixes the problem (and a couple more as 
> well).
> 
> -Travis
> 
> 
> ------------------------------------------------------------------------
> 
> 15c15
> < /* $Id: arrayobject.c,v 1.103 2005/11/04 02:23:22 teoliphant Exp $ */
> ---
> 
>>/* $Id: arrayobject.c,v 1.107 2005/11/09 19:43:39 teoliphant Exp $ */
> 
> 2125a2126,2127
> 
>>    PyArrayInterface *inter=ptr;
>>    
> 
> 2126a2129,2131
> 
>>    if (inter->nd != 0 && (sizeof(int) != sizeof(Py_intptr_t))) {
>>	free(inter->shape);
>>    }
> 
> 2204a2210,2211
> 
>>	    inter->shape = (Py_intptr_t *)malloc(self->nd*2*sizeof(Py_intptr_t));
>>	    inter->strides = inter->shape + (self->nd);
> 
> 2207c2214
> < 		inter->strides[i] = self->dimensions[i];
> ---
> 
>>		inter->strides[i] = self->strides[i];
> 
> 2492a2500,2502
> 
>>static PyArray_Descr *_array_descr_fromstr(char *, int *);
>>
>>
> 
> 2498a2509
> 
>>    PyArray_Descr* descr;
> 
> 2507a2519,2548
> 
>>    
>>    if ((ip=PyObject_GetAttrString(op, "__array_typestr__"))!=NULL) {
>>	int swap=0;
>>	descr=NULL;
>>	if (PyString_Check(ip)) {
>>	    descr = _array_descr_fromstr(PyString_AS_STRING(ip), &swap);
>>	}   
>>	Py_DECREF(ip);
>>	if (descr) {
>>	    return max(minimum_type, descr->type_num);
>>	}
>>    }
>>    else PyErr_Clear();
>>    
>>    if ((ip=PyObject_GetAttrString(op, "__array_struct__")) != NULL) {
>>	PyArrayInterface *inter;
>>	char buf[40];
>>	int swap=0;
>>	descr=NULL;
>>	if (PyCObject_Check(ip)) {
>>	    inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);
>>	    if (inter->version == 2) {
>>		snprintf(buf, 40, "|%c%d", inter->typekind, inter->itemsize);
>>		descr = _array_descr_fromstr(buf, &swap);
>>	    }
>>	}
>>	Py_DECREF(ip);
>>	if (descr) return max(minimum_type, descr->type_num);
>>    }
>>    else PyErr_Clear();
> 
> 2511,2521c2552,2557
> <         if(!ip) {
> <             /* the original code seems to make no provision for the __array__ */
> <             /* call to fail. I do this is a fallback, and the */
> <             /* actual call to __array__ does get checked elsewhere. */
> <             /* maybe ok?  Probably the Python error flag is on at this point*/
> <             /* -- Dubois 3/2002 */
> <             return (int)PyArray_OBJECT;
> <         }
> <         result = max(minimum_type, (int)((PyArrayObject *)ip)->descr->type_num);
> <         Py_DECREF(ip);
> <         return result;
> ---
> 
>>        if(ip && PyArray_Check(ip)) {
>>		result = max(minimum_type, (int)((PyArrayObject *)ip)->descr->type_num);
>>		Py_DECREF(ip);
>>		return result;
>>	}
>>	else Py_XDECREF(ip);
> 
> 2523a2560
> 
>>	
> 
> 3006a3044,3049
> 
>>	    if (!PyArray_Check(op)) {
>>		    Py_DECREF(op);
>>		    PyErr_SetString(PyExc_TypeError,
>>				    "No array interface and __array__"\
>>				    " method not returning Numeric array.");
>>		    return NULL;
> 
> 3007a3051
> 
>>	}
>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Scipy-dev mailing list
>>Scipy-dev at scipy.net
>>http://www.scipy.net/mailman/listinfo/scipy-dev




More information about the SciPy-Dev mailing list