[SciPy-user] weave question

Christian K. ckkart@hoc....
Tue Feb 26 14:37:22 CST 2008


Christoph Scheit wrote:
> Hi everybody,
> 
> I have a small sniplet in C++ that I run using weave.inline
> in a python-script. Now my problem is, that although it should
> be that way, values of mutable arguments passed to the
> c++-part are only changed locally, i.e. after the inlined part
> are the python-arguments still with the same values... Here
> is the sniplet:
> 
>     obsvPtsMinRt = ones(nPts, dtype=int)
> 
>     code = """

[....]

>                obsvPtsMinRt[i] = minrt;
>            }
>            obsvPtsMinRt[3] = 10.;
>            """
>     weave.inline(code,
>                 ['obsvPtsMinRt', 'obsvPtsMaxRt', 'obsvPts', 'eMidPts', 'dt', 'c0'],
>                 type_converters=converters.blitz,
>                 compiler = 'gcc',
>                 headers=["<ios>", "<ostream>", "<sstream>"])
>     
>     print obsvPtsMinRt

I haven't used weave for a long time, but I think it's due using the
wrong kind of brackets. Use () to index the ndarrays. Then I don't
understand why your small example works, though.

Christian



More information about the SciPy-user mailing list