[Numpy-discussion] numpy.i: passing in in-place ND array as "flat" 1D array

Tom Krauss thomas.p.krauss at gmail.com
Mon Mar 23 18:04:18 EDT 2015


I have a method on a C++ object that treats all elements the same and
modifies the array in-place (quantizes each value). Usually I just have a
vector, i.e. a 1D array. But today I wanted to quantize a 2D array, and the

(DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)

failed to do the trick, because of the require_dimensions(array, 1) call.

So I created a new typemap in numpy.i

(DATA_TYPE* INPLACE_ARRAY_FLAT, DIM_TYPE DIM_FLAT)

that omits the call to "require_dimensions", and behold! It works for both
1D and 2D (and really any D).

Does this seem like a reasonable addition to numpy.i? Or is there another
way to do this that I am missing?

Regards,
  Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150323/ed4d5f79/attachment.html>


More information about the NumPy-Discussion mailing list