Hi Andrea On 2014-11-16 19:42:09, Andrea Arteaga <andyspi...@gmail.com> wrote: > My use case is the following: we have a some 3D arrays in our C++ > framework. The ordering of the elements in these arrays is neither C nor > Fortran style: it might be IJK (i.e. C style, 3rd dimension contiguous in > memory), KJI (i.e. Fortran style, first dimension contiguous) or, e.g. IKJ. > Moreover we put some padding to optimize aligned access. This kind of > memory structure cannot be just expressed as 'C' or 'Fortran', but it can > be perfectly expressed using the Python buffer protocol by providing the > shape and the strides. We would like to export this structure to a numpy > array that should be able of accessing the same memory locations in a > consistent way and make some operations like initializing the content or > plotting it. > > Is this currently possible? > If not, is it planned to implement such a feature?
This looks like something that should be accomplished fairly easily using the ``__array_interface__`` dictionary, as described here: http://docs.scipy.org/doc/numpy/reference/arrays.interface.html Any object that exposes a suitable dictionary named ``__array_interface__`` may be converted to a NumPy array. It has the following important keys: shape typestr data: (20495857, True); 2-tuple—pointer to data and boolean to indicate whether memory is read-only strides version: 3 Regards Stéfan _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion