[Numpy-discussion] Numarray design announcement
pete at shinners.org
Mon Jul 22 17:36:12 EDT 2002
Paul F Dubois wrote:
> Numarray's Design
> Paul F. Dubois and Perry Greenfield
a very nice design, for a lot of challenging decisions
> Numarray's current view of arrays in C, using either native or
> emulation C-APIs, is that array data can be mutated, but array
> properties cannot. Thus, an existing Numeric extension function
> which tries to change the shape or strides of an array in C is
> more of a porting challenge, possibly requiring a python wrapper.
i have a c extension that does this, but only during "creation time"
of the array. i'm hoping there can be some way to do this from C. i
need to create a new array from a block of numbers that aren't
/* roughly snipped code */
dim = myimg->w;
dim = myimg->h;
dim = 3; /*r,g,b*/
array = PyArray_FromDimsAndData(3, dim, PyArray_UBYTE, startpixel);
array->flags = OWN_DIMENSIONS|OWN_STRIDES;
array->strides = pixelstep;
array->strides = myimg->pitch;
array->strides = myimg->format->BytesPerPixel;
array->base = myimg_object;
note this data is image data, and i am "reorienting" it so that the
first index is X and the second index is Y. plus i need to account
for an image pitch, where the rows are not exactly the same width as
the number of pixels.
also, i am also changing the "base" field, since the data for this
array lives inside another image object
of course, once the array is created, i pass it off to the user and
never touch these fields again, so perhaps something like this will
work in the new numarray?
if not, i'm eager to start my petition for a
"PyArray_FromDimsAndDataAndStrides" function, and also a way to
assign the "base" as well.
i'm looking forward to the new numarray, looks very exciting.
More information about the NumPy-Discussion