[SciPy-dev] missing Lib/__init__.py in newscipy?

Arnd Baecker arnd.baecker at web.de
Wed Oct 19 15:38:04 CDT 2005


Hi,

I *think* that in fblasmodule.c
`initforcomb` and `nextforcomb` should be changed to

static struct { intp nd, *d; intp *i,*i_tr,tr; } forcombcache;
static int initforcomb(intp *dims,int nd,int tr) {
  int k;
  if (dims==NULL) return 0;
  if (nd<0) return 0;
  forcombcache.nd = nd;
  forcombcache.d = dims;
  forcombcache.tr = tr;
  if ((forcombcache.i = (intp *)malloc(sizeof(intp)*nd))==NULL) return 0;
  if ((forcombcache.i_tr = (intp *)malloc(sizeof(intp)*nd))==NULL) return
0;
  for (k=1;k<nd;k++) {
    forcombcache.i[k] = forcombcache.i_tr[nd-k-1] = 0;
  }
  forcombcache.i[0] = forcombcache.i_tr[nd-1] = -1;
  return 1;
}
static intp *nextforcomb(void) {
  int j,k;
  intp *i,*i_tr;
  intp nd=forcombcache.nd;
  if ((i=forcombcache.i) == NULL) return NULL;
  if ((i_tr=forcombcache.i_tr) == NULL) return NULL;
  if (forcombcache.d == NULL) return NULL;
  i[0]++;
  if (i[0]==forcombcache.d[0]) {
    j=1;
    while ((j<nd) && (i[j]==forcombcache.d[j]-1)) j++;
    if (j==nd) {
      free(i);
      free(i_tr);
      return NULL;
    }
    for (k=0;k<j;k++) i[k] = i_tr[nd-k-1] = 0;
    i[j]++;
    i_tr[nd-j-1]++;
  } else
    i_tr[nd-1]++;
  if (forcombcache.tr) return i_tr;
  return i;
}

This leads to some further warnings, which can be solved
by replacing ` int * ...` by `intp * ...`

build/src/build/src/scipy/linalg/fblasmodule.c: In function
`f2py_rout_fblas_dger':
build/src/build/src/scipy/linalg/fblasmodule.c:8240: warning: assignment
from incompatible pointer type
build/src/build/src/scipy/linalg/fblasmodule.c: In function
`f2py_rout_fblas_cgeru':
build/src/build/src/scipy/linalg/fblasmodule.c:8432: warning: assignment
from incompatible pointer type
build/src/build/src/scipy/linalg/fblasmodule.c: In function
`f2py_rout_fblas_zgeru':
build/src/build/src/scipy/linalg/fblasmodule.c:8624: warning: assignment
from incompatible pointer type
build/src/build/src/scipy/linalg/fblasmodule.c: In function
`f2py_rout_fblas_cgerc':
build/src/build/src/scipy/linalg/fblasmodule.c:8816: warning: assignment
from incompatible pointer type
build/src/build/src/scipy/linalg/fblasmodule.c: In function
`f2py_rout_fblas_zgerc':
build/src/build/src/scipy/linalg/fblasmodule.c:9008: warning: assignment
from incompatible pointer type




After this, the whole test runs through and no segfault!
Ran 386 tests in 9.726s

FAILED (failures=25, errors=165)
Out[2]: <unittest.TextTestRunner object at 0x2aaab4155c10>


(all the errors I can scroll back are of the type:
======================================================================
ERROR: check_simple_transpose_conj
(scipy.linalg.fblas.test_fblas.test_cgemv)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/home/abaecker/BUILDS2/Build_38/inst_scipy_newcore/lib/python2.4/site-packages/scipy/linalg/tests/test_fblas.py",
line 327, in check_simple_transpose_conj
    alpha,beta,a,x,y = self.get_data()
  File
"/home/abaecker/BUILDS2/Build_38/inst_scipy_newcore/lib/python2.4/site-packages/scipy/linalg/tests/test_fblas.py",
line 301, in get_data
    mult = array(1, typecode = self.typecode)
TypeError: 'typecode' is an invalid keyword argument for this function

Most importantly:

In [4]: from scipy.linalg import fblas

In [5]: fblas.sger(1,[1,2],[3,4])
Out[5]:
array([[ 3.,  4.],
       [ 6.,  8.]], dtype=float32)

which is in accordance with the unit test.

I have no idea how to transfer that fix back to the
automatic generation via f2py, so I will leave this for the experts ;-)

Good night, Arnd





More information about the Scipy-dev mailing list