views:

35

answers:

1

I'm trying out scipy.weave to build a fast minimal spanning tree program in Python. Unfortunately, using scipy.weave with a C++ library that I found, STANN, is more difficult that I had assumed. Here's the link to the STANN library: http://sites.google.com/a/compgeom.com/stann/

Below is the Python with scipy.weave script that I wrote.

import scipy.weave as weave
from scipy.weave import inline
import numpy

def gmst(points):
    # computing GMST with STANN headers
    assert(type(points) == type(numpy.array([])))

    # now the c++ code
    code = """
        using namespace std;
        typedef reviver::dpoint<double,2> Point;

        typedef vector<Point>::size_type stype;
        vector< std::pair<stype,stype> > outputmst;
        PyArrayObject *py_val

        gmst(points,outputmst);
        return_val = outputmst;
        """

     return inline(code,['points'], 
        headers = ["<iostream>","<gmst.hpp>","<dpoint.hpp>","<test.hpp>"],
        include_dirs=["/home/tree/usr/STANN/include"])

So far no luck in making weave work. Any ideas why I'm running into a problem? Thanks for the help.

Cheers

A: 

Wrapping external code with weave is a fragile and hacky affair. You should take a look at Cython -- it's great at this sort of stuff.

dwf
I'll take a look at Cython. Thanks for the recommendation.
ebressert