I have been spending hours on the same Cython problem, which I hope
you can solve instantly :-)
I have a Cython file, which happens to be sage/numerical/mip_coin.pyx
which defines the following function :
cdef float osi_solve(self,c_OsiSolverInterface * si,bool log,bool
objective_only)
I would like to use this function outside of mip_coin, so I wrote in
this other file :
cimport sage.numerical.mip_coin
from mip_coin cimport osi_solve
Well, everything seems to be fine in this other module, though when
Sage compiles mip_coin.pyx, it looks at its .pxd file and notices the
following line :
cdef float osi_solve(self,c_OsiSolverInterface * si,bool log,bool
objective_only)
Well, this is (I hope) perfectly normal. As I want to be able to use
this function outside, I have to declare it in the .pxd... But then
Cython tell me the following thing :
/usr/local/sage/devel/sage-cplex/sage/numerical/mip_coin.pxd:88:20:
Non-extern C function 'osi_solve' declared but not defined
So it sounds like Sage does not find the declaration of osi_solve even
though it is made in mip_coin.pyx
Please, tell me that you know where it comes from :-)
Nathann
--
To post to this group, send an email to sage-...@googlegroups.com
To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
Whenever I've run into the above shortcoming in how Python extension
modules worked, I've made a class that provides that method as a
cdef'd method, then instantiated the class.
You should email cython-devel about this, by the way.
-- William
cimport the module and cdef the class. Then you can call C methods.
This sort of thing is used in many places
in Sage, e.g., devel/sage/sage/modular/modsym/p1llist.pyx.
> Nathann
>
> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to
> sage-devel+...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
But when I instanciate the class I can only use its methods as Python functions... My problem is that some arguments are to be C types :-/
Nathann