I don't think we will be able to find a workaround for the stupid numpy issue that prevents us from doing numpy_array[1] = vec3d. At the very best we might hope for a fix in a new version, but whatever we do needs to be compatible for old numpy versions for many years.
In hannorein/rebound/new_reb3d, I simply created a new wrapper class Vec3d which is not a subclass of ctypes.structure. This way I can implement __array_interface__. The new Vec3d class has an attribute which of type _Vec3d - an internal class that is a subclass of ctypes.Structure.
From a user point of view this doesn't change anything. But it does add one extra stumbling block when writing code that accesses the c library. Those functions need the _Vec3d object, not the Vec3d one.
Have a look at the code an tell me what you think.
This is related to what I tried on hannorein/rebound/new_reb3d.
I don't think we will be able to find a workaround for the stupid numpy issue that prevents us from doing
numpy_array[1] = vec3d
. At the very best we might hope for a fix in a new version, but whatever we do needs to be compatible for old numpy versions for many years.In hannorein/rebound/new_reb3d, I simply created a new wrapper class
Vec3d
which is not a subclass ofctypes.structure
. This way I can implement__array_interface__
. The newVec3d
class has an attribute which of type_Vec3d
- an internal class that is a subclass ofctypes.Structure
.From a user point of view this doesn't change anything. But it does add one extra stumbling block when writing code that accesses the c library. Those functions need the
_Vec3d
object, not theVec3d
one.Have a look at the code an tell me what you think.