[Numpy-discussion] Using ndpointer with ctypes argtypes

Josh Mayer joshuaamayer at gmail.com
Sat Mar 12 09:53:42 EST 2011

I found a solution that works. What I did was I wrote a custom class
to define the argtypes. The from_param(obj) method calls ndpointer
when it is a numpy array or if obj is none it returns a null pointer.

On Fri, Mar 11, 2011 at 1:25 PM, Josh Mayer <joshuaamayer at gmail.com> wrote:
> I am trying to call a C function that takes a double array as one of
> its parameters.
> I am using ndpointer to define the argtypes so that I can pass a numpy
> array directly.  The issue I'm having is that this parameter need not
> always be set, and when it is not set, the C functions expects a null
> pointer to a double in it's place. Is there any way I can set up a
> numpy array such that when ndpointer calls from_param() it returns a
> null pointer? Or is there some other way to go about it?
> Thanks

More information about the NumPy-Discussion mailing list