Hi Geoffrey,

Not to toot my own horn here too much, but you really should have a look at
xdress (http://xdress.org/ and https://github.com/xdress/xdress).  XDress
will generate a wrapper of the Force class for you and then also create a
custom numpy dtype for this class.  In this way, you could get exactly what
you want.

If you run into any trouble, let me know and I'll be sure to help you out!
 This is the kind of thing that xdress is *supposed* to do so bugs here are
a big priority for me personally =)

Be Well
Anthony


On Tue, Jul 16, 2013 at 6:44 PM, Geoffrey Irving <irv...@naml.us> wrote:

> Is there a standard way of creating an object array restricted to a
> particular python type?  I want a safe way of sending arrays of
> objects back and forth between Python and C++, and it'd be great if I
> could use numpy arrays on the Python side instead of creating a new
> type.
>
> For example, I might have a C++ class Force which is simultaneously a
> valid Python extension type (also named "Force").  I'd like to be able
> to switch between Array<Force> on the C++ side and a suitable numpy
> array on the Python side, while preventing Python from ever storing an
> object with different type (say, a tuple) in the array.  Note that
> Array<Force> has the memory representation of an array of PyObject*'s.
>
> Thanks,
> Geoffrey
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to