numpy.i: passing in in-place ND array as "flat" 1D array

March 23, 2015
3:04 p.m.
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
3608
Age (days ago)
3608
Last active (days ago)
0 comments
1 participants
participants (1)
-
Tom Krauss