[Numpy-discussion] numpy.i: passing in in-place ND array as "flat" 1D array
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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion